답안 #611408

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
611408 2022-07-29T04:51:05 Z Shithila 커다란 상품 (IOI17_prize) C++14
20 / 100
82 ms 296 KB
#include "prize.h"

int find_best(int n) {
	int start=0;
	int end=n-1;
	int found=false;
	while(found==false)
	{
		int check=start+end;
		check=check/2;
		std::vector<int> res = ask(check);
		if(res[0]==0 && res[1]==0)
		{
			return check;
			found==true;
		}
		else if(res[0]==1)
		{
			end=check;
		}
		else if(res[1]==1)
		{
			start=check;
		}
		if(start==end-1)
		{
			if(check==start)
			{
				return end;
				found==true;
			}
			else
			{
				return start;
				found==true;
			}
		}
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:15:9: warning: statement has no effect [-Wunused-value]
   15 |    found==true;
      |    ~~~~~^~~~~~
prize.cpp:30:10: warning: statement has no effect [-Wunused-value]
   30 |     found==true;
      |     ~~~~~^~~~~~
prize.cpp:35:10: warning: statement has no effect [-Wunused-value]
   35 |     found==true;
      |     ~~~~~^~~~~~
prize.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
   39 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Incorrect 82 ms 208 KB Incorrect
12 Halted 0 ms 0 KB -