Submission #235128

#TimeUsernameProblemLanguageResultExecution timeMemory
235128VimmerSan (COCI17_san)C++14
120 / 120
305 ms504 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 100001 #define M ll(1e9 + 7) #define inf 1e9 + 1e9 using namespace std; typedef long double ld; typedef long long ll; typedef short int si; ll a[50], b[50], f[50], ans, n, m; vector <ll> g[50], vr[50]; void dfs(int v, ll s) { s += b[v]; if (m <= s) {ans += f[v]; return;} for (auto it : g[v]) { dfs(it, s); } } int main() { // freopen("input4.txt", "r", stdin); freopen("output4.txt", "w", stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (ll i = 0; i < n; i++) cin >> a[i] >> b[i]; for (ll i = 0; i < n; i++) for (ll j = i + 1; j < n; j++) if (a[i] <= a[j]) {g[i].pb(j); vr[j].pb(i);} for (ll i = n - 1; i >= 0; i--) { f[i]++; for (auto it : vr[i]) f[it] += f[i]; } for (int i = 0; i < n; i++) dfs(i, 0); cout << ans << endl; }
#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...