# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586824 | krit3379 | Knapsack (NOI18_knapsack) | C++17 | 1086 ms | 36476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 2005
long long dp[N],ans;
vector<pair<int,int>> g[N],op;
int main(){
int n,s,i,v,w,k,cnt;
scanf("%d %d",&s,&n);
for(i=1;i<=n;i++){
scanf("%d %d %d",&v,&w,&k);
g[w].push_back({v,k});
}
for(i=1;i<=s;i++)sort(g[i].begin(),g[i].end(),greater<pair<int,int>>());
for(i=1;i<=s;i++){
cnt=0;
for(auto [v,k]:g[i]){
if(cnt+k<=s){
cnt+=k;
while(k--)op.push_back({v,i});
}
else{
k=s-cnt;
cnt=s;
while(k--)op.push_back({v,i});
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |