Submission #68539

#TimeUsernameProblemLanguageResultExecution timeMemory
68539tempytemptempBank (IZhO14_bank)C++14
44 / 100
212 ms4960 KiB
/* We found Despacito 5 during contest (not clickbait) */ #include <iostream> #include <cstdio> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <cstring> #include <cfloat> #include <cmath> #include <cassert> #include <locale> #include <string> #include <bitset> #include <functional> #include <climits> #include <iomanip> using namespace std; #define read(x) freopen(x,"r",stdin) #define write(x) freopen(x,"w",stdout) #define cl(a,b) memset(a,b,sizeof(a)) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define ll long long #define ld long double #define vec vector #define vi vec<int> #define heap priority_queue #define res reserve #define pb push_back #define f(x,y,z) for(int x=(y); x<(z); x++) #define fd(x,y,z) for(int x=(y); x>=(z); x--) #define fit(x,y) for(auto x: y) #define srt(x) sort(all(x)) #define rsrt(x) sort(rall(x)) #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) #define pii pair<int,int> #define ppi pair<pii,int> #define pip pair<int,pii> #define mp make_pair #define f1 first #define s2 second #define cdbg(x) cerr<<#x<<" = "<<x<<",\t"; #define cdbl cerr<<"\n----------\n"; #define pow2(x) ((x)*(x)) #define edist(x1, y1, x2, y2) (sqrt((pow2(x1-x2)+pow2(y1-y2)))) #define mdist(x1, y1, x2, y2) (abs((x1)-(x2))+abs((y1)-(y2))) #define y1 FullSensei #define mid ((ss+se)>>1) #define left (si<<1) #define right ((si<<1)+1) #define pi 3.141592653589793 #define popcount __builtin_popcount #define spc ' ' #define endl '\n' #define in insert #define up_b upper_bound #define low_b lower_bound #define Decimal fixed<<setprecision(20) bool checkbit(int x,int y){return (x&(1<<y));} int setbit(int x,int y){return (x^(1<<y));} const int dirs[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; const int mod=1e9+7; const int p1=805306457; const int p2=1610612741; const int INF=1e9; const int N=10; const int M=10; const int MVAL=1e3; int a[N+3], b[20+3]; int n, m; bool dp[N+3][MVAL+3][1<<M]; int main(){ scanf("%d %d",&n,&m); assert((n==1) || (n<=N && m<=M)); f(i,1,n+1) scanf("%d",&a[i]); f(i,0,m) scanf("%d",&b[i]); if(n==1){ f(k,0,1<<m){ int sum=0; f(l,0,m){ if(checkbit(k,l)){ sum+=b[l]; } } if(sum == a[1]){ cout<<"YES"<<endl; return 0; } } cout<<"NO"<<endl; return 0; } else{ f(k,0,1<<m) dp[n+1][0][k]=dp[n][0][k]=true; fd(i,n,1){ f(j,0,a[i]+1){ f(k,0,1<<m){ if(j==0){ dp[i][j][k]|=dp[i+1][a[i+1]][k]; // cerr<<i<<spc<<j<<spc<<k<<spc<<dp[i][j][k]<<endl; continue; } if(k==0) continue; f(l,0,m){ if(checkbit(k,l) && j>=b[l]){ dp[i][j][k]|=dp[i][j-b[l]][setbit(k,l)]; } } } } } if(dp[1][a[1]][(1<<m)-1]==1){ cout<<"YES"<<endl; } else{ cout<<"NO"<<endl; } // f(i,0,a[n]+1){ // cerr<<dp[n][i][(1<<m)-1]<<endl; // } return 0; } return 0; } //2 5 //3 2 //2 1 1 1 10

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:81:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
bank.cpp:84:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  f(i,1,n+1) scanf("%d",&a[i]);
             ~~~~~^~~~~~~~~~~~
bank.cpp:85:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  f(i,0,m) scanf("%d",&b[i]);
           ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...