앞사람의 인출 시간이 적을 때 전체 인출 시간이 적어진다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| #include <iostream> #include <algorithm> using namespace std; int main() { int time[1001]; int a; cin >> a; for(int i = 0; i < a; i++) cin >> time[i]; sort(time, time + a); long long b = 0; for(int i = 0; i < a; i++) for(int j = 0; j < i + 1; j++) b += time[j]; cout << b; }
|