Submission #1075593

# Submission time Handle Problem Language Result Execution time Memory
1075593 2024-08-26T07:56:00 Z Abito The Big Prize (IOI17_prize) C++17
20 / 100
36 ms 3264 KB
#include "prize.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int ans[N][2],S;
int32_t find_best(int32_t n) {
	int s=0,mx=0;
	for (int i=0;i<min(500,n);i++){
		vector<int32_t> v=ask(i);
		ans[i][0]=v[0];
		ans[i][1]=v[1];
		if (v[0]+v[1]==0) return i;
		if (v[0]+v[1]>mx){
			mx=v[0]+v[1];
			s=i;
		}
	}
	int sq=sqrtl(n),mn=LLONG_MAX;
	for (int i=1;i<=n;i++){
		int x=sq+(n-sq)/i+mx*i;
		if (x<mn) mn=x,S=i;
	}	
	assert(mn<=10000);
	//cout<<s<<endl;
	for (int i=s;i+S<n;i+=S){
		vector<int32_t> v=ask(i+S);
		ans[i+S][0]=v[0];
		ans[i+S][1]=v[1];
		if (v[0]+v[1]==0) return i+S;
		if (v[0]==ans[i][0] && v[1]==ans[i][1]) continue;
		for (int j=i+1;j<i+S;j++){
			v=ask(j);
			ans[j][0]=v[0];
			ans[j][1]=v[1];
			if (v[0]+v[1]==0) return j;
		}
	}
	for (int i=max(0LL,n-S);i<n;i++){
		vector<int32_t> v=ask(i);
		ans[i][0]=v[0];
		ans[i][1]=v[1];
		if (v[0]+v[1]==0) return i;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 700 KB Output is correct
2 Correct 5 ms 1728 KB Output is correct
3 Correct 8 ms 1492 KB Output is correct
4 Correct 6 ms 2244 KB Output is correct
5 Correct 7 ms 1368 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 5 ms 1220 KB Output is correct
8 Correct 6 ms 1236 KB Output is correct
9 Correct 5 ms 1368 KB Output is correct
10 Correct 8 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 600 KB Output is correct
2 Correct 7 ms 1368 KB Output is correct
3 Correct 8 ms 1368 KB Output is correct
4 Correct 8 ms 2240 KB Output is correct
5 Correct 5 ms 1368 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 6 ms 1208 KB Output is correct
8 Correct 6 ms 1368 KB Output is correct
9 Correct 5 ms 1368 KB Output is correct
10 Correct 10 ms 2232 KB Output is correct
11 Correct 13 ms 1624 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Partially correct 36 ms 3264 KB Partially correct - number of queries: 5558
14 Correct 6 ms 344 KB Output is correct
15 Runtime error 3 ms 436 KB Execution killed with signal 6
16 Halted 0 ms 0 KB -