답안 #607681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
607681 2022-07-27T00:27:01 Z Dan4Life 커다란 상품 (IOI17_prize) C++17
90 / 100
89 ms 1944 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
 
int fenwick[300000]{0}, N;
int sum(int x){
	int s = 0;
	for(; x>0; x-=(x&-x))
		s+=fenwick[x];
	return s;
}
 
int query(int a, int b){return sum(b)-sum(a-1);}
 
void update(int x, int v){
	for(; x <= N; x+=(x&-x))
		fenwick[x]+=v;
}
map<int, vector<int>> M;

vector<int> Ask(int x){
	if(M.count(x)) return M[x];
	return M[x] = ask(x);
}
int find_best(int n) {
	N=n; int l = -1, r = n-1;
	for(int i = 0; i < 500; i++){
		l++, r = n-1;
		while(l+1<r){
			int mid = (l+r)/2;
			auto x = Ask(mid);
			if(x[0]+x[1]==0) return mid;
          	if(x[0]!=query(0,mid-1)) r=mid-1;
          	else  l = mid+1;
		}
		auto x = Ask(l), y = Ask(r);
      	if(x[0]+x[1]==0) return l;
        if(y[0]+y[1]==0) return r;
		if(y[0]!=query(0,r-1)) update(l,1);
		else update(r,1);
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 280 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 2 ms 456 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 3 ms 680 KB Output is correct
14 Correct 3 ms 428 KB Output is correct
15 Correct 8 ms 428 KB Output is correct
16 Partially correct 59 ms 1572 KB Partially correct - number of queries: 6557
17 Correct 1 ms 208 KB Output is correct
18 Partially correct 53 ms 1848 KB Partially correct - number of queries: 7690
19 Correct 1 ms 296 KB Output is correct
20 Correct 17 ms 568 KB Output is correct
21 Correct 33 ms 800 KB Output is correct
22 Correct 7 ms 420 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 296 KB Output is correct
25 Correct 33 ms 1184 KB Output is correct
26 Correct 31 ms 1096 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Partially correct 75 ms 1748 KB Partially correct - number of queries: 7248
29 Partially correct 58 ms 1448 KB Partially correct - number of queries: 5514
30 Partially correct 64 ms 1848 KB Partially correct - number of queries: 7636
31 Correct 0 ms 208 KB Output is correct
32 Correct 5 ms 548 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 24 ms 788 KB Output is correct
35 Correct 2 ms 292 KB Output is correct
36 Correct 23 ms 660 KB Output is correct
37 Correct 1 ms 280 KB Output is correct
38 Correct 1 ms 296 KB Output is correct
39 Correct 30 ms 980 KB Output is correct
40 Partially correct 55 ms 1728 KB Partially correct - number of queries: 6530
41 Correct 41 ms 1188 KB Output is correct
42 Correct 21 ms 1220 KB Output is correct
43 Correct 42 ms 1056 KB Output is correct
44 Correct 29 ms 856 KB Output is correct
45 Correct 26 ms 972 KB Output is correct
46 Correct 1 ms 276 KB Output is correct
47 Correct 29 ms 968 KB Output is correct
48 Partially correct 61 ms 1428 KB Partially correct - number of queries: 5708
49 Correct 6 ms 420 KB Output is correct
50 Partially correct 43 ms 1884 KB Partially correct - number of queries: 7691
51 Correct 38 ms 928 KB Output is correct
52 Correct 1 ms 288 KB Output is correct
53 Correct 2 ms 320 KB Output is correct
54 Correct 38 ms 912 KB Output is correct
55 Correct 1 ms 208 KB Output is correct
56 Partially correct 47 ms 1880 KB Partially correct - number of queries: 7686
57 Partially correct 26 ms 1444 KB Partially correct - number of queries: 5612
58 Partially correct 30 ms 1452 KB Partially correct - number of queries: 5698
59 Correct 37 ms 1216 KB Output is correct
60 Correct 44 ms 1096 KB Output is correct
61 Correct 1 ms 352 KB Output is correct
62 Correct 1 ms 296 KB Output is correct
63 Correct 3 ms 548 KB Output is correct
64 Correct 1 ms 336 KB Output is correct
65 Correct 3 ms 280 KB Output is correct
66 Correct 1 ms 208 KB Output is correct
67 Correct 1 ms 208 KB Output is correct
68 Correct 0 ms 208 KB Output is correct
69 Correct 1 ms 300 KB Output is correct
70 Correct 1 ms 304 KB Output is correct
71 Partially correct 89 ms 1876 KB Partially correct - number of queries: 7790
72 Correct 6 ms 592 KB Output is correct
73 Partially correct 47 ms 1804 KB Partially correct - number of queries: 7668
74 Partially correct 82 ms 1780 KB Partially correct - number of queries: 7710
75 Correct 3 ms 336 KB Output is correct
76 Partially correct 55 ms 1840 KB Partially correct - number of queries: 6625
77 Partially correct 56 ms 1796 KB Partially correct - number of queries: 7730
78 Correct 7 ms 684 KB Output is correct
79 Correct 36 ms 1400 KB Output is correct
80 Partially correct 39 ms 1884 KB Partially correct - number of queries: 7751
81 Partially correct 48 ms 1836 KB Partially correct - number of queries: 7710
82 Partially correct 56 ms 1900 KB Partially correct - number of queries: 7668
83 Correct 2 ms 432 KB Output is correct
84 Partially correct 58 ms 1692 KB Partially correct - number of queries: 6344
85 Partially correct 79 ms 1944 KB Partially correct - number of queries: 7733
86 Correct 14 ms 628 KB Output is correct
87 Correct 3 ms 472 KB Output is correct
88 Correct 6 ms 600 KB Output is correct
89 Correct 9 ms 592 KB Output is correct
90 Correct 2 ms 336 KB Output is correct
91 Correct 11 ms 464 KB Output is correct
92 Correct 7 ms 360 KB Output is correct
93 Correct 5 ms 464 KB Output is correct
94 Correct 4 ms 464 KB Output is correct
95 Correct 4 ms 548 KB Output is correct
96 Correct 5 ms 592 KB Output is correct
97 Correct 1 ms 208 KB Output is correct