Submission #1275131

#TimeUsernameProblemLanguageResultExecution timeMemory
1275131almazBank (IZhO14_bank)C++17
71 / 100
1096 ms22224 KiB
#include <iostream> #include <vector> #include <set> #include <unordered_map> using namespace std; #define endl '\n' signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n , m; scanf( "%d%d" ,&n , &m); vector <int> a(n) , b(m); for(int i = 0;i < n;i++){ scanf("%d" ,&a[i]); } for(int i = 0;i < m;i++){ scanf("%d" ,&b[i]); } vector <vector <int>> mp(200000); for(int i = 0;i < (1 << m);i++){ int sum = 0; for(int j = 0;j < m;j++){ if(1 & (i >> j)){ sum += b[j]; } } if(sum <= 200000) mp[sum].push_back(i); } set <int> g; g.insert(0); for(int i = 0;i < n;i++){ set <int> cnt; for(int j : mp[a[i]]){ for(int k : g){ if((k & j) == 0){ cnt.insert(k | j); } } } swap(cnt , g); } int f = 0; if(g.size() > 0){ f = 1; } if(f){ printf("YES"); } else{ printf("NO"); } }

Compilation message (stderr)

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