Submission #173603

#TimeUsernameProblemLanguageResultExecution timeMemory
173603touristBank (IZhO14_bank)C++14
71 / 100
902 ms1884 KiB
#include <iostream> #include <time.h> #include <vector> using namespace std; #define ll long long #define sz(x) (int)x.size() #define pii pair < int, int > #define endl "\n" #define METH ios::sync_with_stdio(0); cin.tie(0); #define BEGIN cout << "BEGIN" << endl; #define END cout << "END" << endl; const int mod = 1e9 + 7; /// ANOTHER HASH MOD: 228228227 const int prime = 29; /// ANOTHER HASH PRIME: 997 const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8); int n, m, global; vector < short > a, b; bool dp[21][1 << 20]; inline void read() { scanf("%d %d", &n, &m); a.resize(n + 1); b.resize(m + 1); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < m; i++) { scanf("%d", &b[i]); } } void calc(int used, short cur, short sum) { if (double((double)clock() - global) / CLOCKS_PER_SEC == 0.9) { cout << "NO" << endl; exit(0); } if (dp[cur][used]) { return; } if (cur == n) { cout << "YES" << endl; exit(0); } if (sum == a[cur]) { calc(used, cur + 1, 0); return; } if (used == (1 << m) - 1) { return; } for (int i = 0; i < m; i++) { if (used >> i & 1) { continue; } calc(used | (1 << i), cur, sum + b[i]); } dp[cur][used] = 1; } inline int solve() { global = clock(); calc(0, 0, 0); cout << "NO" << endl; } int main() { global = clock(); int t = 1; while (t--) { read(); solve(); } }

Compilation message (stderr)

bank.cpp: In function 'void read()':
bank.cpp:28:20: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<short int> >::value_type* {aka short int*}' [-Wformat=]
   scanf("%d", &a[i]);
                    ^
bank.cpp:31:20: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<short int> >::value_type* {aka short int*}' [-Wformat=]
   scanf("%d", &b[i]);
                    ^
bank.cpp: In function 'int solve()':
bank.cpp:67:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
bank.cpp: In function 'void read()':
bank.cpp:24: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:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
bank.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   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...