Submission #1288666

#TimeUsernameProblemLanguageResultExecution timeMemory
1288666cubed123Labels (NOI20_labels)C++20
7 / 100
1095 ms6244 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define yes cout<<"YES\n" #define no cout<<"NO\n" #define endl '\n' #define pb(x) push_back(x) const int MOD = 1e9+7; const int inf =1e9; const ll INF = 1e15; const ll INV2 = 500000004; // SOLUTION STARTS FROM HERE // void solve() { int n; cin>>n; vector<int> a(n-1); for (int i=0; i<n-1; i++) cin>>a[i]; vector<ll> pref(n); pref[0]=0; for (int i = 1; i < n; ++i) pref[i] = pref[i-1] + a[i-1]; ll mins=pref[0]; ll maxs=pref[0]; ll curs=0; for (int i = 1; i < n; ++i) { mins = min(mins, pref[i]); maxs = max(maxs, pref[i]); } ll l=1-mins; ll r=n - maxs; if (l>r) swap(r, l); ll cnt=0; ll val=-1; for (int i=l; i<=r; i++) { bool pos=true; vector<ll> seen(n+1, false); for (int j=1; j<n-1 && pos; j++) { ll aj = pref[j]+i; if (!(1<=aj && aj<=n)) pos=false; if (seen[aj]) pos=false; seen[aj]=true; } if (pos) { cnt++; val=i; } } if (cnt==1) { for (int i=0; i<n; i++) { cout<<pref[i]+val<<" "; } } else { cout<<-1<<endl; } } bool multi=false; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t=1; if (multi) cin>>t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...