답안 #1029209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029209 2024-07-20T13:50:25 Z amirhoseinfar1385 커다란 상품 (IOI17_prize) C++17
20 / 100
1 ms 344 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
map<int,pair<int,int>>mp;
 
pair<int,int>pors(int u){
	if(mp.count(u)==0){
		vector<int>hey=ask(u);
		mp[u]=make_pair(hey[0],hey[1]);
	}
	return mp[u];
}
 
int find_best(int n) {
	mp.clear();
	int cnta=0;
	for(int i=0;i<n;){
		//cout<<i<<endl;
		pair<int,int>av=pors(i);
		if(av.first+av.second==0){
			return i;
		}
		cnta++;
		pair<int,int>fake;
		int low=i,high=n,mid,f=0;
		for(auto x:mp){
			mid=x.first;
			fake=pors(mid);
			if(fake.first+fake.second!=av.first+av.second){
				if(fake.first+fake.second>av.first+av.second){
					i++;
					f=1;
					break;
				}
				high=mid;
			}else{
				if(fake.first-av.first==0){
					low=mid;
				}else{
					high=mid;
				}
			}
		}
		if(f){
			break;
		}
		low=max(low,i);
		high=n;
		while(high-low>1){
			mid=(high+low)>>1;
			fake=pors(mid);
			if(fake.first+fake.second!=av.first+av.second){
				if(fake.first+fake.second>av.first+av.second){
					break;
				}
				high=mid;
			}else{
				if(fake.first-av.first==0){
					low=mid;
				}else{
					high=mid;
				}
			}
		}
		i=low+1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 0 ms 344 KB answer is not correct
12 Halted 0 ms 0 KB -