제출 #447010

#제출 시각아이디문제언어결과실행 시간메모리
447010cpp219Knapsack (NOI18_knapsack)C++14
100 / 100
74 ms3692 KiB
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 2e3 + 9; const ll Log2 = 21; const ll inf = 1e9 + 7; vector<LL> v[N]; ll s,n,a,b,c,dp[N]; int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>s>>n; for (ll i = 1;i <= n;i++){ cin>>a>>b>>c; v[b].push_back({a,c}); } for (ll i = 1;i <= s;i++){ sort(v[i].begin(),v[i].end(),greater<LL> ()); ll total = i; for (auto now : v[i]){ if (total > s) break; for (ll j = 1;j <= now.sc&&total <= s;j++,total += i) for (ll k = s;k >= i;k--) dp[k] = max(dp[k],dp[k - i] + now.fs); } } cout<<dp[s]; }

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

knapsack.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
knapsack.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
knapsack.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
knapsack.cpp: In function 'int main()':
knapsack.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...