제출 #804694

#제출 시각아이디문제언어결과실행 시간메모리
804694Ellinor커다란 상품 (IOI17_prize)C++14
20 / 100
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

#include "prize.h"

int find_best(int n) 
{
    int ans;
    int low = 0, high = n - 1;
    int mid;
    while (low <= high)
    {
        mid = (low + high) / 2;

        std::vector<int> res = ask(mid);
        if(res[0] + res[1] == 0) ans = mid;

        if (res[0] > res[1]) high = mid - 1;
        else low = mid + 1;
    }

	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int find_best(int)':
prize.cpp:27:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |  return ans;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...