제출 #1072202

#제출 시각아이디문제언어결과실행 시간메모리
1072202KALARRY은행 (IZhO14_bank)C++14
100 / 100
128 ms8632 KiB
//chockolateman #include<bits/stdc++.h> using namespace std; int N,M,a[25],b[25],dp[(1<<20)],left_overs[(1<<20)]; int main() { scanf("%d%d",&N,&M); for(int i = 0 ; i < N ; i++) scanf("%d",&a[i]); for(int j = 0 ; j < M ; j++) scanf("%d",&b[j]); dp[0] = -1; for(int mask = 1 ; mask < (1<<M) ; mask++) { dp[mask] = -1; int sum = 0; for(int j = 0 ; j < M ; j++) if(mask & (1<<j)) sum += b[j]; left_overs[mask] = sum; for(int j = 0 ; j < M ; j++) if(mask & (1<<j)) { int cur_pos = dp[mask ^ (1<<j)]; int money_avail = left_overs[mask ^ (1<<j)] + b[j]; if(money_avail==a[cur_pos+1]) { if(dp[mask] < cur_pos+1) { dp[mask] = cur_pos + 1; left_overs[mask] = 0; } } else { if(dp[mask] < cur_pos) { dp[mask] = cur_pos; left_overs[mask] = money_avail; } } } } if(dp[(1<<M) - 1]==(N-1)) printf("YES\n"); else printf("NO\n"); return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d",&N,&M);
      |     ~~~~~^~~~~~~~~~~~~~
bank.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
bank.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d",&b[j]);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...