Submission #1172134

#TimeUsernameProblemLanguageResultExecution timeMemory
1172134M_W_13Jelly Flavours (IOI20_jelly)C++20
100 / 100
38 ms540 KiB
#include "jelly.h" #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; #define pb push_back #define st first #define nd second const int MAXA = 1e4 + 7; struct pam { int wyn; int suma; }; pam dp[MAXA]; bool por(pair<int, int> a, pair<int, int> b) { return a.nd < b.nd; } int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) { int n = a.size(); pair<int, int> T[n]; rep(i, n) { T[i].st = a[i]; T[i].nd = b[i]; } sort(T, T + n, por); rep(i, n) { a[i] = T[i].st; b[i] = T[i].nd; } rep(i, MAXA) { dp[i] = {0, 0}; } rep(i, n) { for (int j = MAXA - 1; j >= 0; j--) { if (j < a[i]) { if (dp[j].suma + b[i] <= y) { dp[j] = {dp[j].wyn + 1, dp[j].suma + b[i]}; } } else { if (dp[j].suma + b[i] <= y) { dp[j] = {dp[j].wyn + 1, dp[j].suma + b[i]}; } if (dp[j - a[i]].wyn + 1 > dp[j].wyn) { dp[j].wyn = dp[j - a[i]].wyn + 1; } else if (dp[j - a[i]].wyn + 1 == dp[j].wyn) { dp[j].suma = min(dp[j].suma, dp[j - a[i]].suma); } } } } return dp[x].wyn; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...