#include <iostream>
#include <cmath>
#include <stdio.h>
#include <array>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#define pp pair<int,int>
#define pll pair<ll, ll>
#define ll long long
using namespace std;
map<int, int> checking;
ll prefix[300001];
ll answers[300001];
int main() {
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
ll n;
cin >> n;
ll maxi = 0;
for (int i = 1; i < n; i++) {
ll a;
cin >> a;
prefix[i] = prefix[i-1]+a;
maxi = max(prefix[i], maxi);
}
ll amount = n-maxi;
answers[0] = amount;
//cout << amount << endl;
checking[amount] = 1;
for (int i = 1; i < n; i++) {
answers[i] = amount+prefix[i];
//cout << answers[i] << " ";
}
//cout << endl;
ll flag = 0;
for (int i = 0; i < n; i++) {
if ((answers[i] <= 0) && (answers[i] >= n+1)) {
flag = 1;
break;
}
}
if (flag == 1) {
cout << "-1" << endl;
return 0;
}
for (int i = 0; i < n; i++) {
if (i == n-1) {
cout << answers[i] << endl;
} else {
cout << answers[i] << " ";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
7020 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
106 ms |
7168 KB |
Output is correct |
4 |
Incorrect |
91 ms |
7148 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |