Submission #200615

#TimeUsernameProblemLanguageResultExecution timeMemory
200615TadijaSebezEditor (BOI15_edi)C++11
63 / 100
113 ms4216 KiB
#include <bits/stdc++.h> using namespace std; const int N=300050; int a[N]; int main(){ int n,mn=0; scanf("%i",&n); for(int i=1;i<=n;i++)scanf("%i",&a[i]),mn=min(mn,a[i]); if(mn>=-1){ stack<int> stk; for(int i=1;i<=n;i++){ if(a[i]>0)stk.push(a[i]); else if(stk.size())stk.pop(); if(stk.size())printf("%i\n",stk.top()); else printf("0\n"); } } else{ for(int i=1;i<=n;i++){ stack<int> stk; int ans=0; if(i==n||n<=5000){ for(int j=i;j>=1;j--){ if(stk.size()&&a[j]>stk.top()){ stk.pop(); }else{ if(a[j]>0){ans=a[j];break;} stk.push(a[j]); } } } printf("%i\n",ans); } } return 0; }

Compilation message (stderr)

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