Submission #883426

#TimeUsernameProblemLanguageResultExecution timeMemory
883426ComGa999msSan (COCI17_san)C++17
48 / 120
182 ms444 KiB
#include <bits/stdc++.h> #define all(v) (v).begin(), (v).end() #define int long long #define rep(i, l, r) for (int i = l; i <= r; ++i) #define repd(i, r, l) for (int i = r; i >= l; --i) #define _unique(x) (x).resize(unique((x).begin(), (x).end()) - (x).begin()); #define sz(v) (int)(v).size() #define fi first #define se second #define pb push_back #define pf push_front #define mp make_pair #define eps double(1e-9) #define vii vector<int> #define pii pair<int,int> #define p2i pair<int,pii> #define endl '\n' using namespace std; const int N = 1e6 + 5; const int MN = 2e3 + 5; const int mod = 1e9 + 7; const int inf = 1e18 + 7; const bool Emily = false; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l, int r) { return l+rng()%(r-l+1); } bool minimize(int &a, int b) { if (a > b) { a = b; return 1; } return 0; } bool maximize(int &a, int b) { if (a < b) { a = b; return 1; } return 0; } int n, k; pair <int, int> a[N]; void solve(void) { cin >> n >> k; rep(i, 0, n - 1) cin >> a[i].fi >> a[i].se; int res = 0; rep(mask, 0, (1 << n) - 1) { vector <pii> candidates; #define bit(x, i) (1LL & (x >> i)) rep(i, 0, n - 1) if (bit(mask, i)) { candidates.push_back(a[i]); } bool ok = true; rep(i, 1, sz(candidates) - 1) { if (candidates[i - 1] > candidates[i]) { ok = false; break; } } int temp = 0; rep(i, 0, sz(candidates) - 1) temp += candidates[i].se; if (temp < k) ok = false; res += ok; } cout << res << endl; } signed main() { #define task "GDREAM" ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); if (Emily) { int t; cin >> t; while (t-- ) solve(); } else solve(); return 0; }
#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...