# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
122657 | 2019-06-29T05:00:48 Z | SirCeness | 커다란 상품 (IOI17_prize) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; int arr[200005]; int n; int tmp[200005]; // 22 int find_best(int size){ n = size; for (int i = 0; i < size; i++) arr[i] = i; int maxx = 0; for (int i = 0; i < min(10, n); i++){ int* ans = ask(i); maxx = max(ans[0] + ans[1], maxx); } int tmpsize = 0; for (int i = 0; i < maxx; i++){ int l = 0; int r = n-1; while (l < r){ int m = (l+r+1)/2; int *ans = ask(arr[m]); if (ans[0] > i) r = m-1; else l = m; } tmp[tmpsize++] = arr[l+1]; } for (int i = 0; i < tmpsize; i++){ arr[i] = tmp[i]; } n = tmpsize; maxx = 0; for (int i = 0; i < min(10, n); i++){ int* ans = ask(i); maxx = max(ans[0] + ans[1], maxx); } tmpsize = 0; for (int i = 0; i < maxx; i++){ int l = 0; int r = n-1; while (l < r){ int m = (l+r+1)/2; int *ans = ask(arr[m]); if (ans[0] > i) r = m-1; else l = m; } tmp[tmpsize++] = arr[l+1]; } for (int i = 0; i < n; i++){ int *ans = ask(arr[i]); if (ans[0] == 0 && ans[1] == 0){ return arr[i]; } } assert(0); }