티스토리 뷰

블록의 최대값 

#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;
}
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/11   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
글 보관함