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
#include <iostream>
 
using namespace std;
 
int main() {
    int n;
    int p[1000];
    int result = 0;
    int temp = 0;
 
    cin >> n;
 
    for (int i = 0; i < n; i++) { // 입력받기
        cin >> p[i];
    }
 
    for (int i = 0; i < n; i++) { // 오름차순 정렬
        for (int j = i + 1; j < n; j++) {
            if (p[i] > p[j]) {
                temp = p[i];
                p[i] = p[j];
                p[j] = temp;
            }
        }
    }
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            result += p[j];
        }
    }
 
    cout << result;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter

 

 

+ Recent posts