| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1300114 | BuiDucManh123 | Labels (NOI20_labels) | C++20 | 34 ms | 4748 KiB |
#include <bits/stdc++.h>
#define TN ""
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int a[300009], d[300009];
void Solve(){
int n;
cin >> n;
int mi = 0;
int sum = 0;
for(int i = 1; i < n; i++){
cin >> d[i];
sum += d[i];
mi = min(mi, sum);
}
a[1] = -mi + 1;
bool check = false;
if(a[1] > n){
cout << -1;
return;
}
for(int i = 1; i < n; i++){
a[i + 1] = a[i] + d[i];
if(a[i + 1] > n){
cout << -1;
return;
}
}
for(int i = 1; i <= n; i++){
if(a[i] == n){
check = true;
}
}
if(!check){
cout << -1;
return;
}
for(int i = 1; i <= n; i++){
cout << a[i] << " ";
}
}
signed main() {
if(fopen(TN".inp", "r")){
freopen(TN".inp", "r", stdin);
freopen(TN".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int test = 1;
//cin >> test;
while(test--){
Solve();
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
