Submission #46090

#TimeUsernameProblemLanguageResultExecution timeMemory
46090grumpy_gordonEditor (BOI15_edi)C++17
43 / 100
249 ms60776 KiB
#include <cstdio> #include <cstdlib> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #define SIZE 300005 #define BT 20 using namespace std; int A[SIZE]; int par[SIZE][BT]; int mn[SIZE][BT]; int ans[SIZE]; int main() { int n; scanf("%d",&n); memset(par,-1,sizeof(par)); memset(mn,-1,sizeof(mn)); for(int i=0;i<n;i++) { int a; scanf("%d",&a); if(a>0) { ans[i]=a; par[i][0]=i; } else { a=-a; int to=i-1; for(int j=BT-1;j>=0;j--) { if(mn[to][j]>=a) { to=par[to][j]; } } to--; if(to==-1) { ans[i]=0; mn[i][0]=a; } else { ans[i]=ans[to]; int now=to,c=a; for(int j=0;j<BT;j++) { par[i][j]=now; mn[i][j]=c; if(now!=-1) { c=mn[now][j]; now=par[now][j]; } } } } printf("%d\n",ans[i]); } return 0; }

Compilation message (stderr)

edi.cpp: In function 'int main()':
edi.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
edi.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...