#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const int INF = 1e9 + 228;
const int MAXN = 48;
map<int, int> dp[MAXN];
signed main()
{
#ifdef LOCAL
FILE;
#endif
sh;
int n, k;
cin >> n >> k;
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
int aa, bb;
cin >> aa >> bb;
v.pb({aa, bb});
}
int ans = 0;
for (int i = 0; i < n; i++) {
dp[i][min(v[i].S, k)]++;
for (int j = 0; j < i; j++) {
if (v[i].F < v[j].F)
continue;
//print2(i, j);
for (auto to : dp[j]) {
dp[i][min(to.F + v[i].S, k)] += to.S;
}
}
}
for (int i = 0; i < n; i++) {
for (auto to : dp[i]) {
if (to.F >= k) {
ans += to.S;
}
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
4856 KB |
Output is correct |
2 |
Correct |
4 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
15 ms |
3448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
10152 KB |
Output is correct |
2 |
Runtime error |
449 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |