답안 #528517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528517 2022-02-20T12:36:30 Z new_acc 커다란 상품 (IOI17_prize) C++14
90 / 100
93 ms 1976 KB
#include<bits/stdc++.h>
#include "prize.h"
#define fi first
#define se second
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=2e5+10;
int t[N];
int t2[N][2];
set<int>s;
int n,ile;
vi que(int a){
	if(t2[a][0]){
		vi akt;
		akt.push_back(t2[a][0]),akt.push_back(t2[a][1]);
		return akt;
	}
	vi akt=ask(a);
	t2[a][0]=akt[0],t2[a][1]=akt[1];
	return akt;
}
int bs(int pocz,int kon,int x,int l){
	int sr;
	while(pocz<=kon){
		sr=(pocz+kon)/2;
		vi a=que(sr);
		ile++;
		if(a[0]+a[1]==0) return -(sr+1);
		if(a[0]+a[1]!=x) return sr;
		if(a[0]>l) kon=sr-1;
		else pocz=sr+1;
	}	
	return INT_MAX;
}
int find_best(int m){
	n=m;	
	int l=0;
	int ind=0,p=500;
	int maxi=0;
	if(p*p!=n) p++;
	for(int i=0;i<=min(n,p);i++){
		vi a=que(i);
		maxi=max(maxi,a[0]+a[1]);
		t[i]=a[0]+a[1];
		if(t[i]==0) return i;
	}
	while(ind<n-1){
		s.insert(ind);
		if(t[ind]==maxi) {p=t[ind];break;}
		ind++,l++;
	}	
	auto it=s.end();
	it--;
	s.insert(n);
	while(*it!=n){
		auto it2=it;
		it2++;
		ile=0;
		int k=*it2-1;
		vi akt=que(k);
		while(k>=*it+1 and akt[0]+akt[1]!=maxi){
			if(akt[0]+akt[1]==0) return k;
			s.insert(k),k--,akt=que(k);
		}
		if(k>=*it+1){
			vi akt=que(k);
			if(akt[0]+akt[1]==0) return k;
			if(akt[0]==l){
				l++,it++;
				continue;
			}
		}else {l++,it++;continue;}
		int pom=bs(*it+1,k,p,l);
		if(pom!=INT_MAX){
			if(pom<0) return abs(pom)-1;
			s.insert(pom);
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 296 KB Output is correct
2 Correct 6 ms 292 KB Output is correct
3 Correct 6 ms 284 KB Output is correct
4 Correct 5 ms 328 KB Output is correct
5 Correct 2 ms 328 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 3 ms 288 KB Output is correct
8 Correct 2 ms 308 KB Output is correct
9 Correct 6 ms 296 KB Output is correct
10 Correct 5 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 284 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 5 ms 320 KB Output is correct
4 Correct 3 ms 288 KB Output is correct
5 Correct 3 ms 292 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 2 ms 304 KB Output is correct
8 Correct 6 ms 288 KB Output is correct
9 Correct 4 ms 288 KB Output is correct
10 Correct 6 ms 304 KB Output is correct
11 Correct 4 ms 580 KB Output is correct
12 Correct 5 ms 280 KB Output is correct
13 Correct 5 ms 972 KB Output is correct
14 Correct 9 ms 300 KB Output is correct
15 Correct 16 ms 928 KB Output is correct
16 Partially correct 27 ms 1832 KB Partially correct - number of queries: 6767
17 Correct 5 ms 200 KB Output is correct
18 Partially correct 93 ms 1836 KB Partially correct - number of queries: 7856
19 Correct 5 ms 292 KB Output is correct
20 Correct 18 ms 820 KB Output is correct
21 Correct 19 ms 892 KB Output is correct
22 Correct 11 ms 728 KB Output is correct
23 Correct 6 ms 284 KB Output is correct
24 Correct 3 ms 300 KB Output is correct
25 Correct 46 ms 1312 KB Output is correct
26 Correct 36 ms 1436 KB Output is correct
27 Correct 6 ms 412 KB Output is correct
28 Partially correct 68 ms 1828 KB Partially correct - number of queries: 6557
29 Partially correct 59 ms 1712 KB Partially correct - number of queries: 5063
30 Partially correct 30 ms 1852 KB Partially correct - number of queries: 7755
31 Correct 3 ms 292 KB Output is correct
32 Correct 5 ms 848 KB Output is correct
33 Correct 0 ms 200 KB Output is correct
34 Correct 22 ms 1136 KB Output is correct
35 Correct 7 ms 472 KB Output is correct
36 Correct 16 ms 1052 KB Output is correct
37 Correct 5 ms 540 KB Output is correct
38 Correct 5 ms 276 KB Output is correct
39 Correct 38 ms 1364 KB Output is correct
40 Partially correct 75 ms 1764 KB Partially correct - number of queries: 6770
41 Correct 44 ms 1552 KB Output is correct
42 Correct 46 ms 1576 KB Output is correct
43 Correct 34 ms 1440 KB Output is correct
44 Correct 26 ms 1184 KB Output is correct
45 Correct 12 ms 1028 KB Output is correct
46 Correct 6 ms 280 KB Output is correct
47 Correct 29 ms 1252 KB Output is correct
48 Partially correct 31 ms 1608 KB Partially correct - number of queries: 5967
49 Correct 12 ms 704 KB Output is correct
50 Partially correct 60 ms 1800 KB Partially correct - number of queries: 7848
51 Correct 48 ms 1332 KB Output is correct
52 Correct 6 ms 292 KB Output is correct
53 Correct 5 ms 408 KB Output is correct
54 Correct 27 ms 1296 KB Output is correct
55 Correct 6 ms 284 KB Output is correct
56 Partially correct 71 ms 1912 KB Partially correct - number of queries: 7835
57 Partially correct 50 ms 1580 KB Partially correct - number of queries: 5798
58 Correct 67 ms 1508 KB Output is correct
59 Correct 38 ms 1472 KB Output is correct
60 Correct 16 ms 1380 KB Output is correct
61 Correct 5 ms 408 KB Output is correct
62 Correct 5 ms 284 KB Output is correct
63 Correct 9 ms 412 KB Output is correct
64 Correct 6 ms 328 KB Output is correct
65 Correct 3 ms 336 KB Output is correct
66 Correct 6 ms 292 KB Output is correct
67 Correct 9 ms 292 KB Output is correct
68 Correct 4 ms 200 KB Output is correct
69 Correct 5 ms 200 KB Output is correct
70 Correct 9 ms 288 KB Output is correct
71 Partially correct 67 ms 1860 KB Partially correct - number of queries: 8280
72 Correct 13 ms 1072 KB Output is correct
73 Partially correct 85 ms 1752 KB Partially correct - number of queries: 8155
74 Partially correct 66 ms 1816 KB Partially correct - number of queries: 8225
75 Correct 6 ms 488 KB Output is correct
76 Partially correct 45 ms 1824 KB Partially correct - number of queries: 7137
77 Partially correct 77 ms 1976 KB Partially correct - number of queries: 7522
78 Correct 12 ms 1080 KB Output is correct
79 Correct 15 ms 1832 KB Output is correct
80 Partially correct 38 ms 1840 KB Partially correct - number of queries: 7369
81 Partially correct 44 ms 1804 KB Partially correct - number of queries: 7607
82 Partially correct 48 ms 1840 KB Partially correct - number of queries: 7181
83 Correct 5 ms 456 KB Output is correct
84 Partially correct 30 ms 1792 KB Partially correct - number of queries: 6071
85 Partially correct 59 ms 1760 KB Partially correct - number of queries: 7207
86 Correct 6 ms 304 KB Output is correct
87 Correct 6 ms 288 KB Output is correct
88 Correct 8 ms 308 KB Output is correct
89 Correct 2 ms 308 KB Output is correct
90 Correct 5 ms 308 KB Output is correct
91 Correct 6 ms 308 KB Output is correct
92 Correct 6 ms 328 KB Output is correct
93 Correct 10 ms 816 KB Output is correct
94 Correct 10 ms 924 KB Output is correct
95 Correct 6 ms 848 KB Output is correct
96 Correct 9 ms 712 KB Output is correct
97 Correct 5 ms 328 KB Output is correct