This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// This code is written by _L__
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const int mod = 1e9+7, N = 2e5+13, inf = 1e9+1;
const ld E = 1e-6;
#define ff first
#define ss second
ll n, k,h[45], c[45], ans = 0;
void go(int idx, int prev, ll coins){
if(idx >= n) if(coins >= k){ans++;return;}else{return;}
if(h[idx] >= h[prev]){
go(idx+1, idx, coins+c[idx]);
}
go(idx+1, prev, coins);
}
int main(void){
F_word;
cin >> n >> k;
for(int i = 0; i < n; ++i) cin >> h[i] >> c[i];
go(0,0,0); cout << ans%mod << endl;
}
Compilation message (stderr)
san.cpp: In function 'void go(int, int, ll)':
san.cpp:15:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
15 | if(idx >= n) if(coins >= k){ans++;return;}else{return;}
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |