Submission #744643

# Submission time Handle Problem Language Result Execution time Memory
744643 2023-05-18T21:58:05 Z oolimry Archery (IOI09_archery) C++17
6 / 100
85 ms 28440 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
typedef long long lint;
typedef pair<lint,lint> ii;

int arr[400005];
int target[400005];
int n, R; 
int me;

int solve(int s){
	target[me] = s;
	for(int i = 1;i <= 2*n;i++){
		int newi = i + (i >= 2*s);
		target[arr[i]] = (newi+1)/2;
	}
	
	//for(int i = 1;i <= 2*n;i++) show2(i, target[i]);
	
	if(me >= n+2){ ///weak
		set<int> available;
		for(int i = 2;i <= n;i++) available.insert(i);
		
		for(int i = 2*n;i >= me;i--){
			auto it = available.upper_bound(target[i]);
			
			if(it == available.begin()) it = available.end();
			else it--;
						
			if(i == me) return *it;
			available.erase(it);
		}
	}
	else{ ///strong
		assert(false);
	}
}


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n >> R;
	cin >> me;
	
	if(me == 1){
		cout << n;
		return 0;
	}
	
	for(int i = 1;i <= 2*n-1;i++) cin >> arr[i];
	

	
	int bestPos = -1;
	int bestVal = n;

	for(int t = 1;t <= n;t++){
		int res = solve(t);
		if(res <= bestVal){
			bestVal = res;
			bestPos = t; 
		}
	}
	
	cout << bestPos;
}

Compilation message

archery.cpp: In function 'int solve(int)':
archery.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Runtime error 1 ms 596 KB Execution killed with signal 6
5 Correct 1 ms 212 KB Output is correct
6 Correct 3 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Runtime error 2 ms 468 KB Execution killed with signal 6
3 Runtime error 1 ms 464 KB Execution killed with signal 6
4 Runtime error 4 ms 1168 KB Execution killed with signal 6
5 Runtime error 31 ms 8056 KB Execution killed with signal 6
6 Runtime error 1 ms 468 KB Execution killed with signal 6
7 Runtime error 1 ms 464 KB Execution killed with signal 6
8 Runtime error 3 ms 1108 KB Execution killed with signal 6
9 Runtime error 4 ms 1336 KB Execution killed with signal 6
10 Runtime error 1 ms 468 KB Execution killed with signal 6
11 Runtime error 5 ms 1352 KB Execution killed with signal 6
12 Runtime error 1 ms 596 KB Execution killed with signal 6
13 Runtime error 21 ms 5976 KB Execution killed with signal 6
14 Runtime error 2 ms 724 KB Execution killed with signal 6
15 Runtime error 6 ms 1876 KB Execution killed with signal 6
16 Runtime error 1 ms 468 KB Execution killed with signal 6
17 Runtime error 1 ms 468 KB Execution killed with signal 6
18 Runtime error 2 ms 596 KB Execution killed with signal 6
19 Runtime error 2 ms 640 KB Execution killed with signal 6
20 Runtime error 2 ms 724 KB Execution killed with signal 6
21 Runtime error 5 ms 1364 KB Execution killed with signal 6
22 Runtime error 6 ms 1748 KB Execution killed with signal 6
23 Runtime error 32 ms 8464 KB Execution killed with signal 6
24 Runtime error 1 ms 468 KB Execution killed with signal 6
25 Runtime error 2 ms 596 KB Execution killed with signal 6
26 Runtime error 3 ms 1108 KB Execution killed with signal 6
27 Runtime error 9 ms 3412 KB Execution killed with signal 6
28 Runtime error 52 ms 18212 KB Execution killed with signal 6
29 Runtime error 1 ms 596 KB Execution killed with signal 6
30 Runtime error 2 ms 1108 KB Execution killed with signal 6
31 Runtime error 8 ms 3184 KB Execution killed with signal 6
32 Runtime error 84 ms 24956 KB Execution killed with signal 11
33 Runtime error 1 ms 468 KB Execution killed with signal 6
34 Correct 3 ms 340 KB Output is correct
35 Runtime error 2 ms 724 KB Execution killed with signal 6
36 Runtime error 2 ms 724 KB Execution killed with signal 6
37 Runtime error 7 ms 2772 KB Execution killed with signal 6
38 Runtime error 10 ms 3912 KB Execution killed with signal 6
39 Runtime error 1 ms 460 KB Execution killed with signal 6
40 Runtime error 1 ms 596 KB Execution killed with signal 6
41 Runtime error 2 ms 724 KB Execution killed with signal 6
42 Runtime error 1 ms 724 KB Execution killed with signal 6
43 Runtime error 3 ms 1108 KB Execution killed with signal 6
44 Runtime error 4 ms 1876 KB Execution killed with signal 6
45 Runtime error 8 ms 3156 KB Execution killed with signal 6
46 Runtime error 9 ms 3464 KB Execution killed with signal 6
47 Runtime error 85 ms 28440 KB Execution killed with signal 6