Submission #319918

# Submission time Handle Problem Language Result Execution time Memory
319918 2020-11-06T19:04:04 Z gustason San (COCI17_san) C++14
48 / 120
1000 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
ll need, ans = 0;
int h[41], c[41];
void go(ll earned, int curr) {
    //cout << earned << " " << curr << "\n";
    if (earned >= need) {
        ans++;
    }
    for(int i = curr+1; i < n; i++) {
        if (h[curr] > h[i]) continue;
        go(earned + c[i], i);
    }
}
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];
    }

    for(int i = 0; i < n; i++) {
        go(c[i], i);
    }
    cout << ans << "\n";
    return 0;
}
//~ check for overflows
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -