제출 #1094921

#제출 시각아이디문제언어결과실행 시간메모리
1094921rayan_bdKnapsack (NOI18_knapsack)C++17
73 / 100
529 ms5212 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #define ll long long const ll N_INF = -1e9; const int mxN = 150; vector<vector<ll>> dp(mxN,vector<ll>(2001,-1)); pair<int,int> itms[mxN]; ll k[mxN]; int S,N; ll f(int i,int tot){ if(tot<0) return N_INF; if(i<0) return 0; if(dp[i][tot]!=-1) return dp[i][tot]; ll ans=N_INF,cnt=0; while(cnt<=k[i]&&tot-itms[i].second*cnt>=0){ ans=max(ans,f(i-1,tot-itms[i].second*cnt)+itms[i].first*cnt); ++cnt; } return dp[i][tot]=ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int p,w,c;cin>>S>>N; // price,weight,copy for(ll i=0;i<N;++i){ cin>>p>>w>>c; k[i]=c; itms[i]={p,w}; } cout<<f(N-1,S); return 0; }

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

knapsack.cpp:24:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas]
   24 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
knapsack.cpp:31:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas]
   31 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
knapsack.cpp:33:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas]
   33 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
knapsack.cpp:47:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
   47 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
knapsack.cpp:61:19: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   61 | ll f(int i,int tot){
      |                   ^
knapsack.cpp:61:19: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
knapsack.cpp:61:19: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
knapsack.cpp:61:19: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
knapsack.cpp:73:10: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
   73 | int main() {
      |          ^
knapsack.cpp:73:10: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
knapsack.cpp:73:10: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
knapsack.cpp:73:10: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
#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...