結果
問題 | No.1947 質より種類数 |
ユーザー | 蜜蜂 |
提出日時 | 2022-05-06 00:31:46 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 371 ms / 2,000 ms |
コード長 | 1,561 bytes |
コンパイル時間 | 4,461 ms |
コンパイル使用メモリ | 228,608 KB |
実行使用メモリ | 201,868 KB |
最終ジャッジ日時 | 2023-09-18 10:44:19 |
合計ジャッジ時間 | 14,618 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 148 ms
201,652 KB |
testcase_01 | AC | 149 ms
201,640 KB |
testcase_02 | AC | 148 ms
201,636 KB |
testcase_03 | AC | 148 ms
201,672 KB |
testcase_04 | AC | 149 ms
201,712 KB |
testcase_05 | AC | 149 ms
201,688 KB |
testcase_06 | AC | 149 ms
201,688 KB |
testcase_07 | AC | 148 ms
201,688 KB |
testcase_08 | AC | 150 ms
201,712 KB |
testcase_09 | AC | 152 ms
201,736 KB |
testcase_10 | AC | 151 ms
201,816 KB |
testcase_11 | AC | 158 ms
201,760 KB |
testcase_12 | AC | 155 ms
201,652 KB |
testcase_13 | AC | 152 ms
201,844 KB |
testcase_14 | AC | 207 ms
201,660 KB |
testcase_15 | AC | 179 ms
201,780 KB |
testcase_16 | AC | 235 ms
201,732 KB |
testcase_17 | AC | 260 ms
201,696 KB |
testcase_18 | AC | 349 ms
201,812 KB |
testcase_19 | AC | 322 ms
201,868 KB |
testcase_20 | AC | 279 ms
201,728 KB |
testcase_21 | AC | 302 ms
201,840 KB |
testcase_22 | AC | 158 ms
201,716 KB |
testcase_23 | AC | 219 ms
201,780 KB |
testcase_24 | AC | 149 ms
201,700 KB |
testcase_25 | AC | 149 ms
201,720 KB |
testcase_26 | AC | 149 ms
201,824 KB |
testcase_27 | AC | 148 ms
201,716 KB |
testcase_28 | AC | 151 ms
201,688 KB |
testcase_29 | AC | 371 ms
201,760 KB |
testcase_30 | AC | 368 ms
201,812 KB |
testcase_31 | AC | 147 ms
201,748 KB |
testcase_32 | AC | 148 ms
201,644 KB |
testcase_33 | AC | 148 ms
201,752 KB |
testcase_34 | AC | 292 ms
201,760 KB |
testcase_35 | AC | 292 ms
201,748 KB |
testcase_36 | AC | 367 ms
201,744 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:50:10: 警告: 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: 警告: 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; }