# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
749165 |
2023-05-27T12:39:49 Z |
Trent |
Editor (BOI15_edi) |
C++17 |
|
3000 ms |
2164 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 = 3e5 + 10;
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]; 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 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
21 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
30 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
35 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
36 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
1360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
2164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
21 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
30 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
35 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
36 ms |
340 KB |
Output is correct |
10 |
Execution timed out |
3069 ms |
1360 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |