# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
747464 |
2023-05-24T08:06:05 Z |
vjudge1 |
Kralj (COCI16_kralj) |
C++17 |
|
2000 ms |
51408 KB |
#include "bits/stdc++.h"
#define ll long long
using namespace std;
const ll mod = 1000000007;
vector<int> v[500001];
vector<int> vec;
set<int> s;
int ans;
void solve() {
for(int i : vec) {
auto it = s.upper_bound(i);
if(it != s.end()) {
ans++;
s.erase(it);
}
else
s.erase(s.begin());
}
vec.clear();
}
signed main() {
int n;
cin >> n;
int a[n], b[n], c[n], be[n] = {}, en[n] = {};
for(int i = 0; i < n; i++) {
cin >> a[i];
be[a[i] - 1]++;
}
int x = 0;
for(int i = 0; i < n; i++) {
if(be[i]) {
en[(i + be[i] - 1) % n]++;
if(i + be[i] - 1 >= n)
x++;
}
}
int st = 0;
for(int i = 0; i < n; i++) {
x += (be[i] > 0);
if(be[i] && x == 1)
st = i;
x -= en[i];
}
for(int i = 0; i < n; i++)
cin >> b[i];
for(int i = 0; i < n; i++) {
cin >> c[i];
v[a[i] - 1].push_back(c[i]);
}
for(int i = 0; i <= n; i++) {
if(be[st])
solve();
for(int j : v[st])
s.insert(j);
vec.push_back(b[st]);
st++;
st %= n;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1073 ms |
44304 KB |
Output is correct |
2 |
Correct |
827 ms |
43636 KB |
Output is correct |
3 |
Correct |
1128 ms |
50396 KB |
Output is correct |
4 |
Correct |
1087 ms |
51408 KB |
Output is correct |
5 |
Execution timed out |
2067 ms |
25288 KB |
Time limit exceeded |
6 |
Execution timed out |
2065 ms |
25812 KB |
Time limit exceeded |
7 |
Execution timed out |
2079 ms |
28292 KB |
Time limit exceeded |
8 |
Execution timed out |
2082 ms |
26776 KB |
Time limit exceeded |
9 |
Execution timed out |
2071 ms |
28148 KB |
Time limit exceeded |
10 |
Execution timed out |
2073 ms |
25772 KB |
Time limit exceeded |