Submission #797097

#TimeUsernameProblemLanguageResultExecution timeMemory
797097Trisanu_DasSan (COCI17_san)C++17
120 / 120
249 ms300 KiB
#include <bits/stdc++.h> #define ft first #define sd second #define pb push_back using namespace std; typedef long long ll; int n, h[40]; ll k, g[40], ans, f[40]; vector <int> gr[40]; void rec(int v, ll cr) { if (cr >= k) { ans += f[v]; return; } for (int u : gr[v]) rec(u, cr + g[u]); } int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> h[i] >> g[i]; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (h[i] <= h[j]) gr[i].pb(j); for (int i = n - 1; i >= 0; i--) { f[i] = 1; for (int j : gr[i]) f[i] += f[j]; } for (int i = 0; i < n; i++) rec(i, g[i]); cout << ans; }
#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...