Submission #43022

#TimeUsernameProblemLanguageResultExecution timeMemory
43022milmillinEditor (BOI15_edi)C++14
15 / 100
83 ms2516 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<int> undo; vector<int> states; bool isActive() { return undo.size()%2==0; } int main () { int n; scanf("%d", &n); states.push_back(0); int x; bool tmp; for (int i = 0; i < n; i++) { scanf("%d", &x); if (x > 0) { if (!isActive()) states.pop_back(); undo.clear(); states.push_back(x); } else { if (states.back() != 0) { x = -x; tmp = (!isActive() && (undo.empty() || x <= undo.front())); while (!undo.empty() && undo.back() >= x) undo.pop_back(); if (tmp) states.pop_back(); undo.push_back(x); } } //for (auto j : states) printf("%d ", j); //printf("\n"); //for (auto j : undo) printf("%d ", j); //printf("\n"); printf("%d\n", (isActive())?states.back():states[states.size()-2]); } return 0; }

Compilation message (stderr)

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