Submission #1122789

#TimeUsernameProblemLanguageResultExecution timeMemory
1122789ChocoLabels (NOI20_labels)C++20
100 / 100
51 ms4804 KiB
#include<bits/stdc++.h> using namespace std; #define Study ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define ll long long #define ull unsigned long long #define pb push_back #define ff first #define ss second #define ins insert #define all(x) x.begin(),x.end() #define fori(x,y,z) for(ll x=y;x<=z;x++) const ll INF=1e9; const ll sz=2e5+10; const ll mod=1e9+7; void work(){ ll n; cin>>n; int mx=0; vector<int> d(n-1,0); int sum=0; int mn = INF; for(int i =0;i<n-1;i++){ cin>>d[i]; mx=max(mx , sum+=d[i]); mn=min(mn, sum); } vector<int> arr; int s=n - mx; arr.pb(s); // cout<<s<<endl; if( (s-1 >=1 && (mn + (s-1)>=1) )){ cout<<"-1"<<endl; return; } int pref =s; for(auto v:d){ pref+=v; arr.pb(pref); } for(auto v:arr){ if(v<=0 && v>n ){ cout<<"-1"<<endl; return; } } for(auto v:arr){ cout<<v<<" "; } cout<<endl; } int main(){ Study; ll t=1; //cin>>t; while(t--){ work(); } }
#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...