제출 #337557

#제출 시각아이디문제언어결과실행 시간메모리
337557Kerim은행 (IZhO14_bank)C++17
100 / 100
216 ms89068 KiB
#include "bits/stdc++.h" #define MAXN 100009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int dp[20][1<<20]; vector<int>adj[1024]; int a[20],b[20]; int rec(int pos,int mask){ if(pos<0) return 1; int &ret=dp[pos][mask]; if(~ret) return ret; tr(it,adj[a[pos]]) if(!(mask&(*it)) and rec(pos-1,mask^(*it))) return ret=1; /* for(int sub=mask;sub;--sub,sub&=mask) if(cost[sub]==a[pos] and rec(pos-1,mask^sub)) return ret=1; */ return ret=0; } int main(){ // freopen("file.in", "r", stdin); int n,m; scanf("%d%d",&n,&m); for(int i=0;i<n;i++) scanf("%d",a+i); for(int i=0;i<m;i++) scanf("%d",b+i); for(int i=0;i<(1<<m);i++){ int sum=0; for(int j=0;j<m;j++) if(i>>j&1) sum+=b[j]; if(sum<=1000) adj[sum].pb(i); } memset(dp,-1,sizeof dp); if(rec(n-1,0)) puts("YES"); else puts("NO"); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
bank.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   44 |   scanf("%d",a+i);
      |   ~~~~~^~~~~~~~~~
bank.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |   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...