# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
441531 |
2021-07-05T10:28:41 Z |
elazarkoren |
Exam (eJOI20_exam) |
C++17 |
|
1000 ms |
337652 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#define x first
#define y second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define all(v) v.begin(), v.end()
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
const int MAX_N = 10;
int b[MAX_N];
struct Seg{
int l, r, mid, val = 0, lazy_val = 0;
Seg *lp, *rp;
Seg(int l, int r): l(l), r(r), mid((l + r) / 2) {
if (l + 1 != r) {
lp = new Seg(l, mid);
rp = new Seg(mid, r);
}
}
void push() {
if (lazy_val) {
lp->val = lp->lazy_val = lazy_val;
rp->val = rp->lazy_val = lazy_val;
}
}
void pull() {
val = max(lp->val, rp->val);
}
int query(int a, int b) {
if (a <= l && r <= b) return val;
if (r <= a || b <= l) return 0;
push();
return max(lp->query(a, b), rp->query(a, b));
}
void update(int a, int b, int x) {
if (a <= l && r <= b) {
val = x;
lazy_val = x;
return;
}
if (r <= a || b <= l) return;
push();
lp->update(a, b, x), rp->update(a, b, x);
pull();
}
int Count() {
if (l + 1 == r) {
return val == b[l];
}
push();
return lp->Count() + rp->Count();
}
};
int n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
vi a(n);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
vi per(n + 1);
for (int i = 0; i <= n; i++) per[i] = i;
int ans = 0;
do {
Seg seg(0, n);
for (int i = 0; i < n; i++) seg.update(i, i + 1, a[i]);
for (int i = 0; i < n; i++) {
seg.update(per[i], per[i + 1], seg.query(per[i], per[i + 1]));
if (seg.Count() == 4) {
cout << "";
}
chkmax(ans, seg.Count());
}
} while (next_permutation(all(per)));
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
62 ms |
23016 KB |
Output is correct |
4 |
Execution timed out |
1111 ms |
337652 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1115 ms |
329456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
62 ms |
23016 KB |
Output is correct |
4 |
Execution timed out |
1111 ms |
337652 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
62 ms |
23016 KB |
Output is correct |
4 |
Execution timed out |
1111 ms |
337652 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |