10705 | 2024-04-10 09:42:21 | szil | Összegzések | cpp17 | Accepted 100/100 | 17ms | 4744 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 100'001;
int a[MAXN];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, szum = 0; cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
szum += a[i];
}
if (n == 1) {
cout << "0\n";
} else {
int k = a[n-1] + 1;
vector<int> ans;
for (int i = 1; i <= n; i++) {
if (a[i] < k && i != n-1) {
for (int j = 0; j < a[i] - (i == n); j++) ans.emplace_back(1);
}
else {
if (i == n-1) {
ans.emplace_back(a[i]+1);
}
else {
ans.emplace_back(a[i]);
}
}
}
sort(ans.rbegin(), ans.rend());
for (int i : ans) {
cout << i << " ";
}
cout << "\n";
}
if (n == szum) {
cout << "0\n";
} else {
int pos = 0;
for (int i = 1; i <= n; i++) {
if (a[i] >= 2) pos = i;
}
int x = 1;
for (int i = pos+1; i <= n; i++) {
x += a[i];
}
vector<int> ans = {a[pos] - 1};
for (int i = 1; i < pos; i++) ans.emplace_back(a[i]);
while (x > 0) {
ans.emplace_back(min(a[pos] - 1, x));
x -= min(a[pos] - 1, x);
}
sort(ans.rbegin(), ans.rend());
for (int i : ans) {
if (i > 0) cout << i << " ";
}
cout << "\n";
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1712 KiB | ||||
2 | Accepted | 3ms | 1924 KiB | ||||
3 | Accepted | 3ms | 2284 KiB | ||||
subtask2 | 6/6 | ||||||
4 | Accepted | 3ms | 2456 KiB | ||||
5 | Accepted | 3ms | 2560 KiB | ||||
6 | Accepted | 2ms | 2644 KiB | ||||
7 | Accepted | 2ms | 2732 KiB | ||||
8 | Accepted | 3ms | 2724 KiB | ||||
subtask3 | 6/6 | ||||||
9 | Accepted | 3ms | 2932 KiB | ||||
10 | Accepted | 3ms | 3148 KiB | ||||
11 | Accepted | 3ms | 3240 KiB | ||||
12 | Accepted | 4ms | 3636 KiB | ||||
13 | Accepted | 4ms | 3592 KiB | ||||
subtask4 | 10/10 | ||||||
14 | Accepted | 3ms | 2932 KiB | ||||
15 | Accepted | 3ms | 3148 KiB | ||||
16 | Accepted | 3ms | 3240 KiB | ||||
17 | Accepted | 4ms | 3636 KiB | ||||
18 | Accepted | 4ms | 3592 KiB | ||||
19 | Accepted | 3ms | 3276 KiB | ||||
20 | Accepted | 3ms | 3336 KiB | ||||
21 | Accepted | 14ms | 4704 KiB | ||||
22 | Accepted | 17ms | 4744 KiB | ||||
23 | Accepted | 14ms | 4680 KiB | ||||
subtask5 | 10/10 | ||||||
24 | Accepted | 3ms | 3504 KiB | ||||
25 | Accepted | 3ms | 3660 KiB | ||||
26 | Accepted | 3ms | 3652 KiB | ||||
27 | Accepted | 3ms | 3652 KiB | ||||
28 | Accepted | 3ms | 3660 KiB | ||||
subtask6 | 10/10 | ||||||
29 | Accepted | 3ms | 3868 KiB | ||||
30 | Accepted | 2ms | 3652 KiB | ||||
31 | Accepted | 3ms | 3780 KiB | ||||
32 | Accepted | 2ms | 3864 KiB | ||||
33 | Accepted | 2ms | 3876 KiB | ||||
subtask7 | 58/58 | ||||||
34 | Accepted | 2ms | 3872 KiB | ||||
35 | Accepted | 2ms | 3872 KiB | ||||
36 | Accepted | 3ms | 3888 KiB | ||||
37 | Accepted | 3ms | 2456 KiB | ||||
38 | Accepted | 3ms | 2560 KiB | ||||
39 | Accepted | 2ms | 2644 KiB | ||||
40 | Accepted | 2ms | 2732 KiB | ||||
41 | Accepted | 3ms | 2724 KiB | ||||
42 | Accepted | 3ms | 2932 KiB | ||||
43 | Accepted | 3ms | 3148 KiB | ||||
44 | Accepted | 3ms | 3240 KiB | ||||
45 | Accepted | 4ms | 3636 KiB | ||||
46 | Accepted | 4ms | 3592 KiB | ||||
47 | Accepted | 3ms | 3276 KiB | ||||
48 | Accepted | 3ms | 3336 KiB | ||||
49 | Accepted | 14ms | 4704 KiB | ||||
50 | Accepted | 17ms | 4744 KiB | ||||
51 | Accepted | 3ms | 3660 KiB | ||||
52 | Accepted | 3ms | 3868 KiB | ||||
53 | Accepted | 2ms | 3652 KiB | ||||
54 | Accepted | 3ms | 3780 KiB | ||||
55 | Accepted | 2ms | 3864 KiB | ||||
56 | Accepted | 2ms | 3876 KiB | ||||
57 | Accepted | 3ms | 3888 KiB | ||||
58 | Accepted | 3ms | 3996 KiB | ||||
59 | Accepted | 3ms | 4084 KiB | ||||
60 | Accepted | 3ms | 4084 KiB | ||||
61 | Accepted | 3ms | 4172 KiB | ||||
62 | Accepted | 3ms | 4184 KiB | ||||
63 | Accepted | 3ms | 4184 KiB | ||||
64 | Accepted | 3ms | 4136 KiB | ||||
65 | Accepted | 4ms | 4328 KiB | ||||
66 | Accepted | 6ms | 4484 KiB |