lecture/algorithm - c++
[c++] 블록의 최대값
tonirr
2020. 12. 29. 23:03
블록의 최대값
#include <iostream>
#include <vector>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int a[3][11];
int main() {
//freopen("input.txt", "rt", stdin);
int i, j, n, cnt=0,tmp;
scanf("%d", &n);
for(i=1; i<=2; i++){
for(j=1; j<=n; j++){
scanf("%d", &tmp);
a[i][j] = tmp;
}
}
for(i=1; i<=n; i++){
for(j=n; j>=1; j--){
if(a[1][i]<a[2][j]) cnt+=a[1][i];
else cnt+=a[2][j];
}
}
printf("%d ", cnt);
return 0;
}