Submission #200619

#TimeUsernameProblemLanguageResultExecution timeMemory
200619TadijaSebezEditor (BOI15_edi)C++11
100 / 100
279 ms51324 KiB
#include <bits/stdc++.h> using namespace std; const int N=300050; const int L=19; int a[N],go[N][L],mn[N][L],ans[N]; int main(){ int n; scanf("%i",&n); for(int i=1;i<=n;i++){ scanf("%i",&a[i]); if(a[i]>0)ans[i]=a[i]; else{ int x=-a[i]; int j=i-1; for(int k=L-1;~k;k--)if(mn[j][k]>=x)j=go[j][k]; ans[i]=ans[j-1]; go[i][0]=j-1; mn[i][0]=x; for(int k=1;k<L;k++){ go[i][k]=go[go[i][k-1]][k-1]; mn[i][k]=min(mn[i][k-1],mn[go[i][k-1]][k-1]); } } printf("%i\n",ans[i]); } return 0; }

Compilation message (stderr)

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