Submission #285697

#TimeUsernameProblemLanguageResultExecution timeMemory
285697NintsiChkhaidzeLabels (NOI20_labels)C++14
100 / 100
247 ms9312 KiB
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define f first #define s second #define ll long long #define int long long #define mod 1000000007 #define N 300005 using namespace std; int a[N],X[N]; main (){ int n; cin>>n; for (int i=1;i<n;i++) cin>>a[i]; int minn = 0,maxx = 0,m = 0; for (int i=1;i<n;i++){ m+=a[i]; X[i] = m; minn=min(minn,m); maxx=max(maxx,m); } if (maxx - minn != n - 1){ cout<<-1; return 0; } X[1] = 1 - minn; for (int i=1;i<n;i++) X[i + 1] = X[i] + a[i]; for (int i=1;i<=n;i++) cout<<X[i]<<" "; }

Compilation message (stderr)

Labels.cpp:12:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main (){
      |       ^
#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...