# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
749163 |
2023-05-27T12:38:31 Z |
Trent |
Editor (BOI15_edi) |
C++17 |
|
65 ms |
508 KB |
#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
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 time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
508 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
476 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |