제출 #361584

#제출 시각아이디문제언어결과실행 시간메모리
361584shahriarkhan은행 (IZhO14_bank)C++14
100 / 100
434 ms89156 KiB
#include<bits/stdc++.h> using namespace std ; int main() { int n , m ; scanf("%d%d",&n,&m) ; int a[n+1] , b[m+1] , vis[n+1][1<<m] ; for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ; for(int i = 1 ; i <= m ; ++i) scanf("%d",&b[i]) ; vector<int> pos[n+1] , dp ; for(int i = 1 ; i < (1<<m) ; ++i) { int sum = 0 ; for(int j = 0 ; j < m ; ++j) { if(i&(1<<j)) sum += b[j+1] ; } for(int j = 1 ; j <= n ; ++j) { if(a[j]==sum) pos[j].push_back(i) ; } } for(int i = 0 ; i <= n ; ++i) { for(int j = 0 ; j < (1<<m) ; ++j) { vis[i][j] = 0 ; } } dp.push_back(0) ; for(int i = 1 ; i <= n ; ++i) { vector<int> dp2 ; for(int j : dp) { for(int k : pos[i]) { if(j&k) continue ; if(!vis[i][j|k]) { dp2.push_back(j|k) ; vis[i][j|k] = 1 ; } } } dp = dp2 ; if(dp.empty()) { puts("NO") ; return 0 ; } } puts("YES") ; return 0 ; }

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

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