Submission #311332

# Submission time Handle Problem Language Result Execution time Memory
311332 2020-10-09T23:52:23 Z super_j6 Kralj (COCI16_kralj) C++14
0 / 140
35 ms 6784 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 100000;
int n;
int a[mxn], b[mxn], par[mxn];
vector<int> v[mxn];
set<int> s;

int fnd(int x){
	return x == par[x] ? x : par[x] = fnd(par[x]);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		v[--b[i]].push_back(x);
		par[i] = i;
	}
	
	int st = n - 1;
	for(int i = 0; i < n; st--)
	for(int j = v[st].size(); i < n && j; i++, j--){
		int x = fnd(st);
		par[x] = (x + 1) % n;
		j += v[(x + 1) % n].size();
	}
	st++;
	
	int ret = 0;
	for(int i = 0; i < n; i++){
		int x = (st + i) % n;
		for(int j : v[x]) s.insert(j);
		if(a[x] < *prev(s.end())){
			s.erase(s.lower_bound(a[x]));
			ret++;
		}else{
			s.erase(s.begin());
		}
	}
	
	cout << ret << endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 3456 KB Output isn't correct
2 Incorrect 14 ms 3456 KB Output isn't correct
3 Incorrect 15 ms 3456 KB Output isn't correct
4 Incorrect 14 ms 3456 KB Output isn't correct
5 Runtime error 25 ms 6776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 34 ms 6784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 34 ms 6784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 25 ms 6784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 25 ms 6784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 35 ms 6776 KB Execution killed with signal 11 (could be triggered by violating memory limits)