Submission #330054

#TimeUsernameProblemLanguageResultExecution timeMemory
330054M_WLabels (NOI20_labels)C++14
7 / 100
67 ms5248 KiB
#include <bits/stdc++.h> using namespace std; long long a[300300]; int main(){ long long N, minn = 1, maxx = 1, c = 0; scanf("%lld", &N); a[0] = 1; for(long long i = 1, tmp; i < N; i++){ scanf("%lld", &tmp); a[i] = a[i - 1] + tmp; minn = min(minn, a[i] + c); maxx = max(maxx, a[i] + c); if(minn <= 0) c += 1 - minn; if(maxx > N) c -= maxx - N; } if(minn + c != 1 || maxx + c != N){ printf("-1"); exit(0); } for(long long i = 0; i < N; i++) printf("%lld ", a[i] + c); }

Compilation message (stderr)

Labels.cpp: In function 'int main()':
Labels.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |  scanf("%lld", &N);
      |  ~~~~~^~~~~~~~~~~~
Labels.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |   scanf("%lld", &tmp);
      |   ~~~~~^~~~~~~~~~~~~~
#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...