이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 deb(x) cerr << #x << " = " << x << "\n";
#define deb2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_multiset = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
ll binpow(ll a, ll b) {
//a = a % mod;
ll res = 1;
while ( b > 0) {
if (b&1) {
res = (a*res);//%mod;
}
a = (a*a);//%mod;
b >>= 1;
}
return res;
}
void solve(int tc) {
int n;
cin >> n;
vector<int> v(n-1), p(n);
for (int i = 0; i < n-1; ++i) {
cin >> v[i];
p[i+1] = v[i];
p[i+1] += p[i];
}
int mx = *max_element(all(p));
int mn = *min_element(all(p));
deb2(mx, mn)
deb(n-1)
if (mx-mn!=n-1) {
cout << -1 << '\n';
return;
}
vector<int> ans(n);
ans[0] = n-mx;
for (int i = 1; i < n; ++i) {
ans[i] = ans[i-1] + v[i-1];
}
for (auto x : ans) cout << x << " ";
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) {
solve(i);
}
return 0;
}
# | 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... |