답안 #758484

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

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

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 280 KB Integer 200000 violates the range [0, 199999]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 288 KB Integer 200000 violates the range [0, 199999]
2 Halted 0 ms 0 KB -