# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
946291 | 2024-03-14T13:24:58 Z | Pikachu | 커다란 상품 (IOI17_prize) | C++17 | 50 ms | 6160 KB |
#include <bits/stdc++.h> #include "prize.h" using namespace std; template<typename T> inline bool maxi(T &x, const T &val) { if (x < val) return x = val, true; return false; } template<typename T> inline bool mini(T &x, const T &val) { if (x > val) return x = val, true; return false; } map<int,pair<int,int> > mp[500]; int RandInt(int l, int r) { int ans = 0; for (int i = 0; i < 2; i++) { ans = (ans << 15) | (rand() & ((1 << 15) - 1)); } return ans % (r - l + 1) + l; } const int maxn = 2e5 + 10; pair<int,int> dak[maxn]; bool done; int res; int cntask; pair<int,int> myask(int x) { if (done) return make_pair(-1, -1); if (dak[x].first != -1) return dak[x]; cntask++; if (cntask > 10000) assert(false); vector<int> tmp = ask(x - 1); if (tmp[0] + tmp[1] == 0) { res = x - 1; done = true; } dak[x] = make_pair(tmp[0], tmp[1]); mp[tmp[0] + tmp[1]][x] = dak[x]; return dak[x]; } int find_best(int n) { srand(time(0)); memset(dak, -1, sizeof dak); int maxx = 0; int test = 10; while (test--) { int x = RandInt(1, n); pair<int,int> tmp = myask(x); maxi(maxx, tmp.first + tmp.second); } int cur = 1; while (!done) { pair<int,int> tmp = myask(cur); if (tmp.first + tmp.second != maxx) cur++; else break; } while (!done) { if (myask(cur).second == 0) break; if (myask(cur).second == n - cur) { for (int i = cur + 1; i <= n; i++) { myask(i); } break; } auto it = mp[maxx].upper_bound(cur); int nex = n; if (it != mp[maxx].end()) { nex = it -> first; if (it -> second.second == mp[maxx][cur].second) { cur = nex; continue; } } int mid = (cur + nex) >> 1; while (!done) { pair<int,int> tmp = myask(mid); if (tmp.first + tmp.second != maxx) mid--; else break; } if (mid == cur) { mid = (cur + nex) >> 1; while (!done) { pair<int,int> tmp = myask(mid); if (tmp.first + tmp.second != maxx) mid++; else break; } if (mid == nex) { cur = nex; } else { cur = mid; } continue; } } return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1880 KB | Output is correct |
2 | Correct | 1 ms | 1880 KB | Output is correct |
3 | Correct | 1 ms | 2132 KB | Output is correct |
4 | Correct | 1 ms | 1880 KB | Output is correct |
5 | Correct | 1 ms | 1880 KB | Output is correct |
6 | Correct | 1 ms | 1880 KB | Output is correct |
7 | Correct | 1 ms | 2132 KB | Output is correct |
8 | Correct | 1 ms | 1880 KB | Output is correct |
9 | Correct | 1 ms | 1880 KB | Output is correct |
10 | Correct | 1 ms | 1880 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1876 KB | Output is correct |
2 | Correct | 1 ms | 1880 KB | Output is correct |
3 | Correct | 1 ms | 1880 KB | Output is correct |
4 | Correct | 1 ms | 1880 KB | Output is correct |
5 | Correct | 1 ms | 1880 KB | Output is correct |
6 | Correct | 1 ms | 1880 KB | Output is correct |
7 | Correct | 1 ms | 1880 KB | Output is correct |
8 | Correct | 1 ms | 1880 KB | Output is correct |
9 | Correct | 1 ms | 1992 KB | Output is correct |
10 | Correct | 1 ms | 1880 KB | Output is correct |
11 | Correct | 2 ms | 2032 KB | Output is correct |
12 | Correct | 1 ms | 1880 KB | Output is correct |
13 | Correct | 3 ms | 2548 KB | Output is correct |
14 | Correct | 2 ms | 2288 KB | Output is correct |
15 | Correct | 4 ms | 2316 KB | Output is correct |
16 | Correct | 23 ms | 2596 KB | Output is correct |
17 | Correct | 1 ms | 1880 KB | Output is correct |
18 | Correct | 28 ms | 2676 KB | Output is correct |
19 | Correct | 1 ms | 1880 KB | Output is correct |
20 | Correct | 5 ms | 2580 KB | Output is correct |
21 | Correct | 8 ms | 2600 KB | Output is correct |
22 | Correct | 2 ms | 2288 KB | Output is correct |
23 | Correct | 1 ms | 1992 KB | Output is correct |
24 | Correct | 1 ms | 1880 KB | Output is correct |
25 | Correct | 13 ms | 2624 KB | Output is correct |
26 | Correct | 13 ms | 2868 KB | Output is correct |
27 | Correct | 1 ms | 2032 KB | Output is correct |
28 | Correct | 22 ms | 2560 KB | Output is correct |
29 | Correct | 17 ms | 2660 KB | Output is correct |
30 | Correct | 21 ms | 2824 KB | Output is correct |
31 | Correct | 1 ms | 1876 KB | Output is correct |
32 | Correct | 2 ms | 2284 KB | Output is correct |
33 | Correct | 1 ms | 1880 KB | Output is correct |
34 | Correct | 6 ms | 2600 KB | Output is correct |
35 | Correct | 1 ms | 2028 KB | Output is correct |
36 | Correct | 5 ms | 2824 KB | Output is correct |
37 | Correct | 1 ms | 2024 KB | Output is correct |
38 | Correct | 1 ms | 1880 KB | Output is correct |
39 | Correct | 10 ms | 2624 KB | Output is correct |
40 | Correct | 25 ms | 2880 KB | Output is correct |
41 | Correct | 14 ms | 2544 KB | Output is correct |
42 | Correct | 14 ms | 2628 KB | Output is correct |
43 | Correct | 12 ms | 2500 KB | Output is correct |
44 | Correct | 10 ms | 2360 KB | Output is correct |
45 | Correct | 7 ms | 2564 KB | Output is correct |
46 | Correct | 1 ms | 2040 KB | Output is correct |
47 | Correct | 11 ms | 2848 KB | Output is correct |
48 | Correct | 16 ms | 2028 KB | Output is correct |
49 | Correct | 3 ms | 2288 KB | Output is correct |
50 | Correct | 25 ms | 2992 KB | Output is correct |
51 | Correct | 9 ms | 2836 KB | Output is correct |
52 | Correct | 1 ms | 2028 KB | Output is correct |
53 | Correct | 1 ms | 2028 KB | Output is correct |
54 | Correct | 11 ms | 2356 KB | Output is correct |
55 | Correct | 1 ms | 1880 KB | Output is correct |
56 | Correct | 27 ms | 2836 KB | Output is correct |
57 | Correct | 20 ms | 2616 KB | Output is correct |
58 | Correct | 20 ms | 2952 KB | Output is correct |
59 | Correct | 13 ms | 2632 KB | Output is correct |
60 | Correct | 11 ms | 2424 KB | Output is correct |
61 | Correct | 1 ms | 2036 KB | Output is correct |
62 | Correct | 1 ms | 1880 KB | Output is correct |
63 | Correct | 1 ms | 2028 KB | Output is correct |
64 | Correct | 1 ms | 2168 KB | Output is correct |
65 | Correct | 1 ms | 2024 KB | Output is correct |
66 | Correct | 3 ms | 2288 KB | Output is correct |
67 | Correct | 2 ms | 2032 KB | Output is correct |
68 | Correct | 3 ms | 2540 KB | Output is correct |
69 | Correct | 3 ms | 2284 KB | Output is correct |
70 | Correct | 2 ms | 2036 KB | Output is correct |
71 | Correct | 22 ms | 3020 KB | Output is correct |
72 | Correct | 3 ms | 2052 KB | Output is correct |
73 | Correct | 25 ms | 2384 KB | Output is correct |
74 | Correct | 21 ms | 3216 KB | Output is correct |
75 | Correct | 1 ms | 2028 KB | Output is correct |
76 | Correct | 22 ms | 2912 KB | Output is correct |
77 | Correct | 18 ms | 3076 KB | Output is correct |
78 | Correct | 3 ms | 2284 KB | Output is correct |
79 | Correct | 14 ms | 2808 KB | Output is correct |
80 | Correct | 22 ms | 2792 KB | Output is correct |
81 | Correct | 36 ms | 3064 KB | Output is correct |
82 | Correct | 30 ms | 3108 KB | Output is correct |
83 | Correct | 1 ms | 2028 KB | Output is correct |
84 | Correct | 18 ms | 3172 KB | Output is correct |
85 | Correct | 24 ms | 3204 KB | Output is correct |
86 | Runtime error | 50 ms | 6160 KB | Execution killed with signal 6 |
87 | Halted | 0 ms | 0 KB | - |