Submission #660153

#TimeUsernameProblemLanguageResultExecution timeMemory
660153kinopeEditor (BOI15_edi)C++14
35 / 100
3075 ms8532 KiB
#include <bits/stdc++.h> using namespace std; struct p{ int v; bool on; }; int main(){ int n; scanf("%d", &n); vector<p> act(n); vector<int> ojc(n, -1); set<pair<int, int>> s; for(int i = 0; i < n; ++i){ int a; scanf("%d", &a); if(a > 0){ act[i] = {a, 1}; s.emplace(i, a); printf("%d\n", (*prev(s.end())).second); continue; } act[i] = {a, 1}; for(int j = i-1; ~j; --j) if(act[j].on && act[j].v > a){ ojc[i] = j; for(int x = j; ~x; x = ojc[x]){ act[x].on^=1; if(ojc[x] < 0){ pair<int, int> tmp = {x, act[x].v}; if(act[x].on) s.emplace(x, act[x].v); else s.erase(tmp); } } break; } if(s.empty()) printf("0\n"); else printf("%d\n", (*prev(s.end())).second); } return 0; }

Compilation message (stderr)

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