Submission #631027

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6310272022-08-17 15:02:29thienbao1602Knapsack (NOI18_knapsack)C++17
100 / 100
97 ms36028 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2005;
const ll inf = -1e15;
int S, n;
void solve()
{
cin >> S >> n;
map<ll, vector<pair<ll, ll>>> weight;
for(int i=0; i<n; i++)
{
ll w, val, sl;
cin >> val >> w >> sl;
weight[w].push_back({val, sl});
}
int id = 1;
vector<vector<ll>> ans((int)weight.size()+1, vector<ll>(S+1, inf));
ans[0][0] = 0;
for(auto [w, items] : weight)
{
sort(items.begin(), items.end(), greater<pair<ll, ll>>());
for(int i=0; i<=S; i++)
{
ans[id][i] = ans[id-1][i];
ll sl = 0, profit = 0, type_at = 0, used = 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...