#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define i128 __int128
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define REP1(a) for (int _ = 0; _ < a; ++_)
#define REP2(i, a) for (int i = 0; i < a; ++i)
#define REP3(i, a, b) for (int i = a; i < b; ++i)
#define REP4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define REP(...) overload4(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__)
#define pb push_back
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> using max_heap = priority_queue<T>;
const int MOD = 1e9+7;
const int INF = 1e18;
int32_t main(){
fast_io;
int n;
cin >> n;
int a[n-1];
REP(i, n-1) cin >> a[i];
int b[n] = {1};
REP(i, 1, n) b[i] = b[i-1] + a[i-1];
int inc = 1 - *min_element(b, b+n);
REP(i, n) b[i] += inc;
REP(i, n) {
if (b[i] < 1 || b[i] > n) {
cout << -1;
return 0;
}
}
REP(i, n) cout << b[i] << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
7512 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
45 ms |
7892 KB |
Output is correct |
4 |
Incorrect |
26 ms |
6236 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |