10799 | 2024-04-14 11:45:23 | Ablablabla | Összegzések | cpp17 | Accepted 100/100 | 10ms | 4756 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> alap(n);
int osszeg = 0;
for(int i = 0; i < n; i++){
cin >> alap[i];
osszeg += alap[i];
}
int novelInd = 0;
int elotte = osszeg;
for(int i = n - 1; i >= 1; i--){
if(alap[i] != alap[i - 1] && elotte + 1 <= osszeg){
novelInd = i;
break;
}
elotte -= alap[i];
}
if(n == 1){
cout << "0\n";
} else{
int mas = osszeg;
for(int i = 0; i < novelInd; i++){
cout << alap[i] << " ";
mas -= alap[i];
}
cout << alap[novelInd] + 1 << " ";
mas -= alap[novelInd] + 1;
while(mas > 0){
cout << "1 ";
mas--;
}
cout << "\n";
}
int csokkInd = -1;
for(int i = n - 1; i >= 0; i--){
if(alap[i] != 1){
csokkInd = i;
break;
}
}
if(n == osszeg){
cout << "0\n";
} else{
int mas = osszeg;
for(int i = 0; i < csokkInd; i++){
cout << alap[i] << " ";
mas -= alap[i];
}
int akt = alap[csokkInd] - 1;
cout << akt << " ";
mas -= akt;
while(mas >= akt){
cout << akt << " ";
mas -= akt;
}
if(mas != 0){
cout << mas << " ";
}
cout << "\n";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1712 KiB | ||||
2 | Accepted | 3ms | 2076 KiB | ||||
3 | Accepted | 3ms | 2216 KiB | ||||
subtask2 | 6/6 | ||||||
4 | Accepted | 3ms | 2088 KiB | ||||
5 | Accepted | 3ms | 2300 KiB | ||||
6 | Accepted | 3ms | 2552 KiB | ||||
7 | Accepted | 3ms | 2756 KiB | ||||
8 | Accepted | 3ms | 2960 KiB | ||||
subtask3 | 6/6 | ||||||
9 | Accepted | 3ms | 3016 KiB | ||||
10 | Accepted | 3ms | 3020 KiB | ||||
11 | Accepted | 3ms | 3260 KiB | ||||
12 | Accepted | 4ms | 3412 KiB | ||||
13 | Accepted | 4ms | 3612 KiB | ||||
subtask4 | 10/10 | ||||||
14 | Accepted | 3ms | 3016 KiB | ||||
15 | Accepted | 3ms | 3020 KiB | ||||
16 | Accepted | 3ms | 3260 KiB | ||||
17 | Accepted | 4ms | 3412 KiB | ||||
18 | Accepted | 4ms | 3612 KiB | ||||
19 | Accepted | 3ms | 3436 KiB | ||||
20 | Accepted | 3ms | 3528 KiB | ||||
21 | Accepted | 9ms | 3560 KiB | ||||
22 | Accepted | 10ms | 3560 KiB | ||||
23 | Accepted | 9ms | 3904 KiB | ||||
subtask5 | 10/10 | ||||||
24 | Accepted | 2ms | 3736 KiB | ||||
25 | Accepted | 3ms | 3736 KiB | ||||
26 | Accepted | 3ms | 3736 KiB | ||||
27 | Accepted | 3ms | 3852 KiB | ||||
28 | Accepted | 3ms | 3868 KiB | ||||
subtask6 | 10/10 | ||||||
29 | Accepted | 3ms | 3996 KiB | ||||
30 | Accepted | 3ms | 3996 KiB | ||||
31 | Accepted | 3ms | 4084 KiB | ||||
32 | Accepted | 3ms | 4084 KiB | ||||
33 | Accepted | 3ms | 4200 KiB | ||||
subtask7 | 58/58 | ||||||
34 | Accepted | 3ms | 4200 KiB | ||||
35 | Accepted | 2ms | 4200 KiB | ||||
36 | Accepted | 3ms | 4204 KiB | ||||
37 | Accepted | 3ms | 2088 KiB | ||||
38 | Accepted | 3ms | 2300 KiB | ||||
39 | Accepted | 3ms | 2552 KiB | ||||
40 | Accepted | 3ms | 2756 KiB | ||||
41 | Accepted | 3ms | 2960 KiB | ||||
42 | Accepted | 3ms | 3016 KiB | ||||
43 | Accepted | 3ms | 3020 KiB | ||||
44 | Accepted | 3ms | 3260 KiB | ||||
45 | Accepted | 4ms | 3412 KiB | ||||
46 | Accepted | 4ms | 3612 KiB | ||||
47 | Accepted | 3ms | 3436 KiB | ||||
48 | Accepted | 3ms | 3528 KiB | ||||
49 | Accepted | 9ms | 3560 KiB | ||||
50 | Accepted | 10ms | 3560 KiB | ||||
51 | Accepted | 3ms | 3868 KiB | ||||
52 | Accepted | 3ms | 3996 KiB | ||||
53 | Accepted | 3ms | 3996 KiB | ||||
54 | Accepted | 3ms | 4084 KiB | ||||
55 | Accepted | 3ms | 4084 KiB | ||||
56 | Accepted | 3ms | 4200 KiB | ||||
57 | Accepted | 3ms | 4088 KiB | ||||
58 | Accepted | 3ms | 4208 KiB | ||||
59 | Accepted | 3ms | 4424 KiB | ||||
60 | Accepted | 3ms | 4512 KiB | ||||
61 | Accepted | 3ms | 4508 KiB | ||||
62 | Accepted | 3ms | 4512 KiB | ||||
63 | Accepted | 3ms | 4628 KiB | ||||
64 | Accepted | 4ms | 4644 KiB | ||||
65 | Accepted | 4ms | 4740 KiB | ||||
66 | Accepted | 7ms | 4756 KiB |