# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
749161 |
2023-05-27T12:17:25 Z |
Trent |
Editor (BOI15_edi) |
C++14 |
|
75 ms |
600 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 = i; le[j] > 0; j=pre[j]) {
ac[pre[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 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
16 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
55 ms |
360 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
39 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
43 ms |
388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
75 ms |
592 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
28 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
16 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
55 ms |
360 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
39 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
43 ms |
388 KB |
Output is correct |
10 |
Runtime error |
75 ms |
592 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |