Submission #1446761


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL N,K;
	cin>>N>>K;
	vector<LL> A(N);
	LL i;
	bool allLetter=true;
	for (i=0;i<N;i++){
		cin>>A[i];
		if (A[i]==K){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}else if (A[i]>K){
			allLetter=false;
		}
	}
	if (allLetter){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}

	sort(A.begin(),A.end());
	LL x;
	for (i=0;i<N-1;i++){
		x=A[i]-A[i+1];
		if (x<0){
			x=-x;
		}
		if (x==1 || x==K){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}

	while (true){
		x=A[0]-A[1];
		if (x<0){
			x=-x;
		}
		if (x==1 || x==K){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
		if (x==0){
			cout<<"IMPOSSIBLE"<<endl;
			return 0;
		}
		if (A[1]>A[0]){
			A[1]=x;
		}else{
			A[0]=x;
		}
	}
	return 0;
}

Submission Info

Submission Time
Task A - Getting Difference
User reitetsu
Language C++14 (GCC 5.4.1)
Score 0
Code Size 875 Byte
Status WA
Exec Time 47 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 4
AC × 17
WA × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 47 ms 1024 KB
subtask_1_04.txt AC 1 ms 1024 KB
subtask_1_05.txt AC 22 ms 640 KB
subtask_1_06.txt WA 8 ms 384 KB
subtask_1_07.txt AC 28 ms 768 KB
subtask_1_08.txt AC 35 ms 896 KB
subtask_1_09.txt WA 19 ms 512 KB
subtask_1_10.txt AC 34 ms 768 KB
subtask_1_11.txt AC 32 ms 896 KB