# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
747409 |
2023-05-24T07:04:04 Z |
vjudge1 |
Kralj (COCI16_kralj) |
C++17 |
|
2000 ms |
66292 KB |
#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
#define cerr (cerr << "D: ")
clock_t start_time;
using namespace std;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init(bool oj = 1) {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
srand(time(0)); start_time = clock();
if (oj) {
#ifndef ONLINE_JUDGE
FILE* _ = freopen("in.txt", "r", stdin);
//FILE* __ = freopen("out.txt", "w", stdout);
#endif
}
}
const ll MOD = 1e9 + 7;
const ll N = 5e5 + 7;
const ll M = 2e3 + 7;
//####################################################################################
int n;
bool vis[N];
vector<int> a;
multiset<int> b;
int solve(int i) {
if (i == n)
return 0;
int mx = 0, f = *b.begin();
b.erase(b.begin());
mx = max(mx, solve(i + 1) + (f > a[i]));
b.insert(f);
auto it = b.lower_bound(a[i]);
if (it == b.end())
return mx;
f = *it;
b.erase(it);
mx = max(mx, solve(i + 1) + (f > a[i]));
b.insert(f);
it = b.upper_bound(a[i]);
if (it == b.end())
return mx;
f = *it;
b.erase(it);
mx = max(mx, solve(i + 1) + (f > a[i]));
b.insert(f);
return mx;
}
int main() {
init(0);
cin >> n;
a.resize(n);
for (int i = 0; i < n; i++) {int _; cin >> _;}
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
int x;
cin >> x;
b.insert(x);
}
sort(all(a));
cout << solve(0) << endl;
cerr << get_time() << "s" << endl;
}
Compilation message
kralj.cpp: In function 'void init(bool)':
kralj.cpp:15:9: warning: unused variable '_' [-Wunused-variable]
15 | FILE* _ = freopen("in.txt", "r", stdin);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2074 ms |
53492 KB |
Time limit exceeded |
2 |
Execution timed out |
2071 ms |
52172 KB |
Time limit exceeded |
3 |
Execution timed out |
2074 ms |
64692 KB |
Time limit exceeded |
4 |
Execution timed out |
2066 ms |
66204 KB |
Time limit exceeded |
5 |
Execution timed out |
2074 ms |
60204 KB |
Time limit exceeded |
6 |
Execution timed out |
2025 ms |
60032 KB |
Time limit exceeded |
7 |
Execution timed out |
2013 ms |
62640 KB |
Time limit exceeded |
8 |
Execution timed out |
2060 ms |
56444 KB |
Time limit exceeded |
9 |
Execution timed out |
2024 ms |
66292 KB |
Time limit exceeded |
10 |
Execution timed out |
2082 ms |
66284 KB |
Time limit exceeded |