# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833855 |
2023-08-22T09:04:38 Z |
azik21 |
Bank (IZhO14_bank) |
C++17 |
|
0 ms |
212 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define nn "\n"
#define ex exit(0);
#define sz(s) (int)(s).size()
const int N = 2e5+5;
int cnt , ans , bit , n , t , k ,x , a , b , res , p,sum , r , l ;
char h;
vector<int> v;
int main(){
ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
cin>> n >> t ;
int m[n];
map<int , int >mp;
for(int i =0 ;i < n ; i++){
cin>> m[i];
}
for(int j =0 ; j < t ; j++){
cin>> x ;
mp[x]++;
v.pb(x);
}
sort(all(v));
int p[t+1];
p[0] = 0 ;
for(int i = 0 ; i< t ; i++){
p[i+1]=p[i]+v[i];
}
if(mp[m[0]]>0){
cout<<"YES";
ex;
}
for(int i=0;i < n ; i++){
if(mp[m[i]]>0){
cout<<"YES";
ex;
}
else {
l = 0, r = t - 1;
while (l < r) {
if (v[l] + v[r] == m[i]) {
cout<<"YES";
ex;
}
if (v[l] + v[r] < m[i]) {
l++;
}
if (v[l] + v[r] > m[i]) {
r--;
}
}
break;
}
}
l = 1 ;
for(int i=1 ; i <= t ;i++){
if(p[i]==m[0]){
cout<<"YES";
ex;
}
if(p[i]>m[0]){
while(p[i]>m[0]){
p[i]-=p[l];
l++;
}
if(p[i]==m[0]){
cout<<"YES";
ex;
}
}
}
cout<<"NO";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |