답안 #758429

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758429 2023-06-14T15:36:50 Z Andrey 커다란 상품 (IOI17_prize) C++14
0 / 100
133 ms 292 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;

int find_best(int n) {
	int y = 0,l,r,m,x;
	for(int i = 0; i*i < n; i++) {
        vector<int> a = ask(i);
        if(a[0] == i && a[1] == 0) {
            return i;
        }
        if(a[0] == 0) {
            y = i;
        }
	}
	while(y < n) {
        l = y;
        r = n-1;
        vector<int> a = ask(y);
        x = a[1];
        if(a[0] > 0) {
            if(a[0] == y && a[1] == 0) {
                return y;
            }
            y++;
            continue;
        }
        while(l < r) {
            m = (l+r+1)/2;
            a = ask(m);
            if(a[0] == 0 && a[1] == x) {
                l = m;
            }
            else {
                r = m-1;
            }
        }
        a = ask(l);
        if(a[0] == l && a[1] == 0) {
            return l;
        }
        y = l+1;
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 72 ms 272 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 292 KB Incorrect
2 Halted 0 ms 0 KB -