답안 #25846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25846 2017-06-24T11:31:59 Z szawinis Kralj (COCI16_kralj) C++14
0 / 140
283 ms 10484 KB
#include <bits/stdc++.h>
using namespace std;
const int MAX = (5e5)+1;

int n, start, ans, a[MAX], tmp[MAX], d[MAX], e[MAX];
bool mark[MAX];
multiset<int> st;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i], --a[i];
	copy(a, a+n, tmp);
	sort(tmp, tmp+n);
	int curr = 0;
	for(int x: tmp) {
		if(mark[x]) curr = (curr+1)%n;
		else curr = start = x;
		mark[curr] = true;
	}
	for(int i = 0; i < n; i++) cin >> d[i];
	for(int i = 0; i < n; i++) cin >> e[i];
	for(int z = 0, i = start; z < n; z++, i = (i+1)%n) {
		st.insert(e[i]);
		auto it = st.lower_bound(d[i]);
		if(it != st.end()) ans++, st.erase(it);
		else st.erase(st.begin());
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 10484 KB Output isn't correct
2 Incorrect 156 ms 10484 KB Output isn't correct
3 Incorrect 203 ms 10484 KB Output isn't correct
4 Incorrect 219 ms 10484 KB Output isn't correct
5 Incorrect 236 ms 10484 KB Output isn't correct
6 Incorrect 223 ms 10484 KB Output isn't correct
7 Incorrect 283 ms 10484 KB Output isn't correct
8 Incorrect 209 ms 10484 KB Output isn't correct
9 Incorrect 233 ms 10484 KB Output isn't correct
10 Incorrect 283 ms 10484 KB Output isn't correct