Submission #330049

#TimeUsernameProblemLanguageResultExecution timeMemory
330049oakLabels (NOI20_labels)C++14
100 / 100
114 ms5612 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,i; scanf("%d",&n); int arr[n],mi = 0,mx = 0; arr[0] = 0; for(i=1;i<n;i++){ scanf("%d",&arr[i]); arr[i] += arr[i-1]; if(arr[i] < mi)mi = arr[i]; else if(arr[i] > mx)mx = arr[i]; if(arr[i] > n || -arr[i] > n){ printf("-1"); return 0; } } if(mx-mi+1 < n){ printf("-1"); return 0; } int c = 1 - mi; for(i=0;i<n;i++){ printf("%d ",c+arr[i]); } }

Compilation message (stderr)

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