Submission #381405

#TimeUsernameProblemLanguageResultExecution timeMemory
381405asqarSan (COCI17_san)C++14
48 / 120
56 ms364 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back using namespace std; const ll maxn = 1e5 + 1; ll n, k, H[41], G[41], a, cur, ans; main () { ios_base::sync_with_stdio (0); cin.tie (0); cin >> n >> k; for (ll i = 1; i <= n; i ++) { cin >> H[i] >> G[i]; } ll po = (1 << n); for (ll mask = 0; mask < po; mask ++) { cur = 0, a = 0; for (ll i = mask, j = 1; i >= 0; i = i = (i >> 1),j ++) { //cout << i % 2 << " "; if (i % 2 == 1) { if (cur <= H[j]) { a += G[j]; cur = H[j]; } else { a = 0, cur = 0; break; } } if (i == 0) break; } if (a >= k) ans ++; //cout << " " << a << endl; } cout << ans; }

Compilation message (stderr)

san.cpp:9:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main ()
      |       ^
san.cpp: In function 'int main()':
san.cpp:23:38: warning: operation on 'i' may be undefined [-Wsequence-point]
   23 |   for (ll i = mask, j = 1; i >= 0; i = i = (i >> 1),j ++)
      |                                    ~~^~~~~~~~~~~~~~
san.cpp:23:38: warning: operation on 'i' may be undefined [-Wsequence-point]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...