結果
問題 | No.1947 質より種類数 |
ユーザー |
![]() |
提出日時 | 2022-05-06 00:31:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 325 ms / 2,000 ms |
コード長 | 1,561 bytes |
コンパイル時間 | 3,705 ms |
コンパイル使用メモリ | 231,280 KB |
実行使用メモリ | 201,984 KB |
最終ジャッジ日時 | 2024-07-05 02:08:37 |
合計ジャッジ時間 | 12,409 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:50:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 50 | auto [x,y]=gd[i]; | ^ main.cpp:64:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 64 | auto [x,y]=gd[i]; | ^
ソースコード
//g++ 2.cpp -std=c++14 -O2 -I . #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; using vvld = vector<vld>; using vst = vector<string>; using vvst = vector<vst>; #define fi first #define se second #define pb push_back #define eb emplace_back #define pq_big(T) priority_queue<T,vector<T>,less<T>> #define pq_small(T) priority_queue<T,vector<T>,greater<T>> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) vvi dp(10050,vi(5050,0)); int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,v,c; cin>>n>>v>>c; vector<pair<int,int>> gd(n); rep(i,0,n){ int x,y; cin>>x>>y; gd[i]={x,y}; } int ans=0; rep(i,0,n){ auto [x,y]=gd[i]; rep(j,0,v+1){ dp[i+1][j]=dp[i][j]; ans=max(ans,dp[i+1][j]); } per(j,v,0){ if(j>=x){ dp[i+1][j]=max(dp[i+1][j],dp[i][j-x]+y+c); ans=max(ans,dp[i+1][j]); } } } rep(i,0,n){ auto [x,y]=gd[i]; rep(j,0,v+1){ dp[n+i+1][j]=dp[n+i][j]; ans=max(ans,dp[n+i+1][j]); } rep(j,0,v+1){ if(j+x<=v){ dp[n+i+1][j+x]=max(dp[n+i+1][j+x],dp[n+i+1][j]+y); ans=max(ans,dp[n+i+1][j+x]); } } } cout<<ans<<endl; }