Submission #319915

# Submission time Handle Problem Language Result Execution time Memory
319915 2020-11-06T18:56:28 Z gustason San (COCI17_san) C++14
0 / 120
1000 ms 65540 KB
#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 time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 145 ms 15204 KB Output is correct
2 Incorrect 66 ms 492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 34148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 685 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 27284 KB Time limit exceeded
2 Halted 0 ms 0 KB -