結果

問題 No.467 隠されていたゲーム
ユーザー taba
提出日時 2017-05-18 05:25:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 73,268 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 16:31:21
合計ジャッジ時間 1,998 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <random>
#include <vector>
#include <algorithm>
#include <array>
#include <functional>
#include <utility>

using namespace std;

int main(){
	int n;
	-scanf("%d",&n);
	vector<int> d(n);
	for(int i=0;i<n;i++){
		-scanf("%d",&d[i]);
	}
	int x,y,p,dm;
	-scanf("%d%d",&x,&y);
	p=max(abs(x),abs(y));
	dm=*max_element(d.begin(),d.end());
	if(p==0){
		puts("0");
	}else{
		auto result=find(d.begin(),d.end(),p);
		if(result!=d.end()){
			puts("1");
		}else{
			int i=0;
			while(p>=dm*2){
				p-=dm;
				i++;
			}
			printf("%d\n",i+(p==dm?1:2));
		}
	}
	return 0;
}
0