#include <cstdio> #include <algorithm> const int MAXN = 2010; int a[11010101]; int main() { // freopen("input.txt", "r", stdin); int n; scanf("%d", &n); int m = n * (n + 1); m /= 2; for (int i = 0; i < m; i++) scanf("%d", &a[i]); std::sort(a, a + m); long long ans = 0ll; for (int i = 0; i < n; i++) ans += a[i]; printf("%lld\n", ans); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> #include <algorithm> const int MAXN = 2010; int a[11010101]; int main() { // freopen("input.txt", "r", stdin); int n; scanf("%d", &n); int m = n * (n + 1); m /= 2; for (int i = 0; i < m; i++) scanf("%d", &a[i]); std::sort(a, a + m); long long ans = 0ll; for (int i = 0; i < n; i++) ans += a[i]; printf("%lld\n", ans); return 0; } |