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 31 32 33 34 35 36 37 38 | #include <iostream> #include <algorithm> using namespace std; int main() { for ( int i=1; i<=10; i++) { int dump; cin >> dump; int box[100]; int sum=0; int max_idx, min_idx; int H_max=0; int H_min=101; for ( int j=0; j<100; j++) { cin >> box[j]; if (H_max < box[j]) {H_max=box[j]; max_idx=j;} if (H_min > box[j]) {H_min=box[j]; min_idx=j;} } while (dump--) { box[max_idx]--; box[min_idx]++; H_max=0; H_min=101; for ( int j=0; j<100; j++) { if (H_max < box[j]) {H_max=box[j]; max_idx=j;} if (H_min > box[j]) {H_min=box[j]; min_idx=j;} } } cout << "#" << i << " " <<box[max_idx]-box[min_idx]<< endl; } } |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
171031_string (0) | 2017.10.31 |
---|---|
171031_sum (0) | 2017.10.31 |
171030_view (0) | 2017.10.30 |
171030_간단한 369 게임 (0) | 2017.10.30 |
171028_파리 퇴치 (0) | 2017.10.28 |