Submission #668120

#TimeUsernameProblemLanguageResultExecution timeMemory
668120finn__커다란 상품 (IOI17_prize)C++17
0 / 100
1483 ms296 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; int find_best(int n) { int ans_max = 0; for (size_t i = 0; i * i < n; i++) { vector<int> ans = ask(i); ans_max = max(ans_max, ans[0] + ans[1]); if (!ans[0] && !ans[1]) return i; } int i = -1, found = 0; while (1) { int a = i + 1, b = n - 1; while (a < b) { int mid = (a + b) / 2; vector<int> ans = ask(mid); if (!ans[0] && !ans[1]) return mid; if (ans[0] + ans[1] == ans_max) { if (ans[0] == found) a = mid + 1; else b = mid; } else b = mid; } found++; i = a; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:9:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |     for (size_t i = 0; i * i < n; i++)
      |                        ~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...