이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/********************************** //deque,priority_queue
* author: NurkhatKrutoi2009
* created: Just now
* P.S: tourist ne katai
**********************************/
#include <bits/stdc++.h>
/*
#include <algorithm>
#include <iostream>
#include <cmath>
*//*
#pragma GCC optimize("fast-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2,fma")
#pragma GCC optimization ("unroll-loops")
*/
#define int long long
#define FREOPEN freopen("rvq.in", "r", stdin); freopen("rvq.out", "w", stdout);
#define sonic ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define all(x) (x).begin(), (x).end()
#define pss pair<string,string>
#define nextp next_permutation
#define pii pair<int,int>
#define priq priority_queue
#define mii map<int,int>
#define sz(x) (x).size()
#define str to_string
#define rev reverse
#define pb push_back
#define ll long long
#define endl '\n'
#define S second
#define F first
const int Pi=3.1415926535;
const int inf=1e10+5;
const int MOD=1e9+7;
const int N=1e5+123;
const int lol=63;
using namespace std;
int tc=1;
int n,m;
int s[25];
int v[25];
void code( ){
cin>>n>>m;
FOR(i,1,n,1)cin>>s[i];
FOR(i,1,m,1)cin>>v[i];
if(m<n){ cout<<"NO";return; }
if(m==n){
sort(v+1,v+m+1); sort(s+1,s+n+1);
FOR(i,1,n,1){
if(v[i]!=s[i]){ cout<<"NO";return; }
}cout<<"YES";return;}
if(n==1){
for(int mask=0;mask<(1<<m);mask++){
int sum=0;
for(int i=0;i<m;i++)if(mask & (1<<i))sum+=v[i+1];
if(sum==s[1]){ cout<<"YES";return; }
}cout<<"NO";
return;}
}signed main(){sonic //FREOPEN
//cin>>tc;
while(tc--){
code();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |