제출 #1107579

#제출 시각아이디문제언어결과실행 시간메모리
1107579adkjtKnapsack (NOI18_knapsack)C++14
37 / 100
1040 ms336 KiB
#include<bits/stdc++.h> using namespace std; #define f first #define s second vector<pair<int,int>> V[2222]; int dp[2222]; pair<int,pair<int,int>> a[111111];//v,w,k int main() { int s,n; cin>>s>>n; for(int i=1; i<=n; i++) { cin>>a[i].f>>a[i].s.f>>a[i].s.s; if(a[i].s.f>s) continue; V[a[i].s.f].push_back({-a[i].f,a[i].s.s}); } for(int i=1; i<=s; i++) dp[i]=-1; for(int i=1; i<=s; i++) sort(V[i].begin(),V[i].end()); for(int i=1; i<=s; i++) { if (V[i].empty()) continue; int j = 0; for(int k=1; k<=s/i; i++) { for(auto x:V[i])//v,k { re: for (int w = s; w - i >= 0; w--) { dp[w] = max(dp[w], dp[w - i] - x.f); } x.s--; if (x.s == 0) { continue; } else goto re; } } } int ans=0; for(int i=1; i<=s; i++) ans=max(ans,dp[i]); cout<<ans; }

컴파일 시 표준 에러 (stderr) 메시지

knapsack.cpp: In function 'int main()':
knapsack.cpp:24:13: warning: unused variable 'j' [-Wunused-variable]
   24 |         int j = 0;
      |             ^
#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...