Submission #319915

#TimeUsernameProblemLanguageResultExecution timeMemory
319915gustasonSan (COCI17_san)C++14
0 / 120
1073 ms65540 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, need; int h[41], c[41]; set<vector<int>> s; void go(int earned, int curr, vector<int> steps) { //cout << earned << " " << curr << "\n"; if (s.count(steps)) { return; } if (earned >= need) { s.insert(steps); } for(int i = curr+1; i < n; i++) { if (h[curr] > h[i]) continue; steps.push_back(i); go(earned + c[i], i, steps); steps.pop_back(); } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> need; for(int i = 0; i < n; i++) { cin >> h[i] >> c[i]; } vector<int> start; for(int i = 0; i < n; i++) { start.push_back(i); go(c[i], i, start); start.pop_back(); } cout << s.size() << "\n"; return 0; } //~ check for overflows
#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...