제출 #833655

#제출 시각아이디문제언어결과실행 시간메모리
833655azik21은행 (IZhO14_bank)C++17
0 / 100
1 ms336 KiB
#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(){ 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)); for(int i=0;i < n ; i++){ if(mp[m[i]]>0){ ans++; } else { l = 0, r = t - 1; while (l < r) { if (v[l] + v[r] == m[i]) { ans++; v[l] = 0, v[r] = 0; break; } if (v[l] + v[r] < m[i]) { l++; } if (v[l] + v[r] > m[i]) { r--; } } } } if(ans==n){ cout<<"YES"; ex; } cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...