#include <cstdio> #include <algorithm> using namespace std; #define MAX_N 2000 #define LL long long int n; int C[MAX_N*MAX_N]; int main() { scanf("%d",&n); int counter=0; for(int a=0;a<n;++a) { for(int b=a;b<n;++b) { scanf("%d",&C[counter++]); } } sort(C,C+counter); LL sum=0; for(int a=0;a<n;++a)sum+=C[a]; printf("%lld",sum); return 0; }
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 | #include <cstdio> #include <algorithm> using namespace std; #define MAX_N 2000 #define LL long long int n; int C[MAX_N*MAX_N]; int main() { scanf("%d",&n); int counter=0; for(int a=0;a<n;++a) { for(int b=a;b<n;++b) { scanf("%d",&C[counter++]); } } sort(C,C+counter); LL sum=0; for(int a=0;a<n;++a)sum+=C[a]; printf("%lld",sum); return 0; } |