10993 | 2024-05-03 12:39:16 | EsVagy | Összegzések | cpp17 | Accepted 100/100 | 19ms | 788 KiB |
#include <bits/stdc++.h>
using namespace std;
using t = int;
int main() {
t size;
cin >> size;
vector<t> vec(size);
for (t i = 0; i < size; i++) {
cin >> vec[i];
}
{
t last = vec[vec.size() - 1];
t index = vec.size() - 1;
t sum = 0;
while (true) {
if (index == -1) {
cout << "0\n";
break;
}
sum += vec[index];
if (vec[index - 1] != last || index == 0) {
if (sum == last) {
last = vec[index - 1];
index--;
continue;
}
for (t i = 0; i < index; i++) {
cout << vec[i] << " ";
}
cout << last + 1 << " ";
sum -= last + 1;
while (sum > 0) {
cout << 1 << " ";
sum--;
}
cout << "\n";
break;
}
index--;
}
}
{
t index = vec.size() - 1;
t sum = 0;
while (true) {
if (index == -1) {
cout << "0\n";
break;
}
sum += vec[index];
if (vec[index] == 1) {
index--;
continue;
}
for (t i = 0; i < index; i++) {
cout << vec[i] << " ";
}
cout << vec[index] - 1 << " ";
sum -= vec[index] - 1;
while (sum > 0) {
cout << min(sum, vec[index] - 1) << " ";
sum -= min(sum, vec[index] - 1);
}
cout << "\n";
break;
}
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 2ms | 492 KiB | ||||
2 | Accepted | 3ms | 612 KiB | ||||
3 | Accepted | 3ms | 356 KiB | ||||
subtask2 | 6/6 | ||||||
4 | Accepted | 2ms | 412 KiB | ||||
5 | Accepted | 2ms | 356 KiB | ||||
6 | Accepted | 2ms | 512 KiB | ||||
7 | Accepted | 2ms | 356 KiB | ||||
8 | Accepted | 2ms | 420 KiB | ||||
subtask3 | 6/6 | ||||||
9 | Accepted | 2ms | 356 KiB | ||||
10 | Accepted | 3ms | 408 KiB | ||||
11 | Accepted | 3ms | 408 KiB | ||||
12 | Accepted | 4ms | 500 KiB | ||||
13 | Accepted | 4ms | 536 KiB | ||||
subtask4 | 10/10 | ||||||
14 | Accepted | 2ms | 356 KiB | ||||
15 | Accepted | 3ms | 408 KiB | ||||
16 | Accepted | 3ms | 408 KiB | ||||
17 | Accepted | 4ms | 500 KiB | ||||
18 | Accepted | 4ms | 536 KiB | ||||
19 | Accepted | 3ms | 356 KiB | ||||
20 | Accepted | 3ms | 504 KiB | ||||
21 | Accepted | 17ms | 612 KiB | ||||
22 | Accepted | 19ms | 788 KiB | ||||
23 | Accepted | 17ms | 540 KiB | ||||
subtask5 | 10/10 | ||||||
24 | Accepted | 3ms | 484 KiB | ||||
25 | Accepted | 3ms | 484 KiB | ||||
26 | Accepted | 3ms | 636 KiB | ||||
27 | Accepted | 3ms | 656 KiB | ||||
28 | Accepted | 2ms | 376 KiB | ||||
subtask6 | 10/10 | ||||||
29 | Accepted | 3ms | 484 KiB | ||||
30 | Accepted | 3ms | 420 KiB | ||||
31 | Accepted | 3ms | 536 KiB | ||||
32 | Accepted | 3ms | 384 KiB | ||||
33 | Accepted | 2ms | 376 KiB | ||||
subtask7 | 58/58 | ||||||
34 | Accepted | 2ms | 384 KiB | ||||
35 | Accepted | 3ms | 484 KiB | ||||
36 | Accepted | 3ms | 360 KiB | ||||
37 | Accepted | 2ms | 412 KiB | ||||
38 | Accepted | 2ms | 356 KiB | ||||
39 | Accepted | 2ms | 512 KiB | ||||
40 | Accepted | 2ms | 356 KiB | ||||
41 | Accepted | 2ms | 420 KiB | ||||
42 | Accepted | 2ms | 356 KiB | ||||
43 | Accepted | 3ms | 408 KiB | ||||
44 | Accepted | 3ms | 408 KiB | ||||
45 | Accepted | 4ms | 500 KiB | ||||
46 | Accepted | 4ms | 536 KiB | ||||
47 | Accepted | 3ms | 356 KiB | ||||
48 | Accepted | 3ms | 504 KiB | ||||
49 | Accepted | 17ms | 612 KiB | ||||
50 | Accepted | 19ms | 788 KiB | ||||
51 | Accepted | 2ms | 376 KiB | ||||
52 | Accepted | 3ms | 484 KiB | ||||
53 | Accepted | 3ms | 420 KiB | ||||
54 | Accepted | 3ms | 536 KiB | ||||
55 | Accepted | 3ms | 384 KiB | ||||
56 | Accepted | 2ms | 376 KiB | ||||
57 | Accepted | 3ms | 504 KiB | ||||
58 | Accepted | 2ms | 376 KiB | ||||
59 | Accepted | 2ms | 376 KiB | ||||
60 | Accepted | 3ms | 500 KiB | ||||
61 | Accepted | 2ms | 484 KiB | ||||
62 | Accepted | 3ms | 356 KiB | ||||
63 | Accepted | 3ms | 504 KiB | ||||
64 | Accepted | 4ms | 376 KiB | ||||
65 | Accepted | 4ms | 376 KiB | ||||
66 | Accepted | 7ms | 484 KiB |