Submission #749163

#TimeUsernameProblemLanguageResultExecution timeMemory
749163TrentEditor (BOI15_edi)C++17
0 / 100
65 ms508 KiB
#include "bits/stdc++.h" using namespace std; #define forR(i, a) for(int i = 0; (i) < (a); ++(i)) #define REP(i, a, b) for(int i = (a); (i) < (b); ++i) #define all(a) a.begin(), a.end() #define boost() cin.sync_with_stdio(0); cin.tie(0) #define printArr(arr) for(int asdfg : arr) cout << asdfg << ' '; cout << '\n' #define open(x) freopen(((string) x + ".in").c_str(), "r", stdin); freopen(((string) x + ".out").c_str(), "w", stdout); typedef long long ll; typedef long double ld; struct pii{ll a, b;}; struct tii{ll a, b, c;}; bool operator <(pii a, pii b){ return a.a < b.a || a.a == b.a && a.b < b.b;} const int MN = 5010; bool ac[MN]; int le[MN], pre[MN], va[MN]; signed main(){ int n; cin >> n; REP(i, 1, n + 1){ int v; cin >> v; if(v > 0) ac[i]=true, le[i]=0, va[i]=v, pre[i]=0; else { le[i]=-v, ac[i]=true, pre[i]=0; for(int j = i - 1; j > 0 && pre[i]==0; --j) if(ac[j] && le[j] < le[i]) pre[i]=j; for(int j = pre[i]; le[j] > 0; j=pre[j]) ac[j] = !ac[j]; } int las=0; REP(j, 1, i + 1) if(le[j] == 0 && ac[j]) las = j; cout << va[las] << '\n'; } }

Compilation message (stderr)

edi.cpp: In function 'bool operator<(pii, pii)':
edi.cpp:14:63: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   14 | bool operator <(pii a, pii b){ return a.a < b.a || a.a == b.a && a.b < b.b;}
      |                                                    ~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...