Submission #951478

#TimeUsernameProblemLanguageResultExecution timeMemory
951478Trisanu_DasEditor (BOI15_edi)C++17
20 / 100
3039 ms4372 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; struct pii { ll a, b; }; struct tii { ll a, b, c; }; bool compare_pii(pii a, pii b) { return a.a < b.a || (a.a == b.a && a.b < b.b); } const int MN = 3e5 + 10; bool ac[MN]; int le[MN], pre[MN], va[MN]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { 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]; j != 0; j = pre[j]) ac[j] = !ac[j]; } int las = 0; for (int j = 1; j <= i; ++j) if (le[j] == 0 && ac[j]) las = j; cout << va[las] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...