Submission #998312

#TimeUsernameProblemLanguageResultExecution timeMemory
998312thisisadarshBank (IZhO14_bank)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;

const int sz=1002;
int n,m;
bool answer=true;
int a[sz], b[sz];
int main(){
 	scanf("%d%d", &n,&m);
 	for(int i=0; i<n; ++i){
 		scanf("%d", &a[i]);
 	}
 	for(int j=0; j<m; ++j){
 		scanf("%d", &b[j]);
 	}            
 	for(int i=0; i<n; ++i){
 		 sort(b, b+m);
 	 	int low=0, hi=m-1;
 	 	bool ok=false;
 	 	while(low<hi){
 	 	 	if(b[low]+b[hi]==a[i]){
 	 	 		b[low]=0,b[hi]=0;
 	 	 		ok=true;
 	 	 		break;
 	 	 	}
 	 	  if(b[low]+b[hi]>a[i])hi--;
 	 	  else low++;
 	 	}
 	 	if(!ok){
 	 		answer=false;
 	 		break;
 	 	}
 	}
 	printf("%s\n", (answer?"YES":"NO"));
}

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d%d", &n,&m);
      |   ~~~~~^~~~~~~~~~~~~~~
bank.cpp:11:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |    scanf("%d", &a[i]);
      |    ~~~~~^~~~~~~~~~~~~
bank.cpp:14:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |    scanf("%d", &b[j]);
      |    ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...