結果

問題 No.1676 Coin Trade (Single)
ユーザー milanis48663220milanis48663220
提出日時 2021-09-10 22:06:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,284 bytes
コンパイル時間 1,896 ms
コンパイル使用メモリ 123,512 KB
実行使用メモリ 8,852 KB
最終ジャッジ日時 2023-09-02 17:50:55
合計ジャッジ時間 3,772 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 28 ms
6,932 KB
testcase_04 AC 25 ms
6,400 KB
testcase_05 AC 23 ms
6,180 KB
testcase_06 AC 23 ms
6,224 KB
testcase_07 AC 20 ms
5,360 KB
testcase_08 AC 13 ms
4,368 KB
testcase_09 AC 20 ms
5,360 KB
testcase_10 AC 21 ms
5,368 KB
testcase_11 AC 29 ms
7,236 KB
testcase_12 AC 16 ms
4,640 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 2 ms
4,372 KB
testcase_22 AC 2 ms
4,368 KB
testcase_23 AC 2 ms
4,368 KB
testcase_24 AC 1 ms
4,368 KB
testcase_25 AC 2 ms
4,368 KB
testcase_26 AC 2 ms
4,372 KB
testcase_27 AC 2 ms
4,368 KB
testcase_28 AC 2 ms
4,368 KB
testcase_29 AC 1 ms
4,368 KB
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 1 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 36 ms
8,764 KB
testcase_34 AC 36 ms
8,852 KB
testcase_35 AC 36 ms
8,712 KB
testcase_36 AC 36 ms
8,820 KB
testcase_37 AC 36 ms
8,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, k; cin >> n >> k;
    vector<int> a(n), m(n);
    vector<vector<int>> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> m[i];
        b[i].resize(m[i]);
        for(int j = 0; j < m[i]; j++) {
            cin >> b[i][j];
            b[i][j]--;
        }
    }
    vector<ll> dp(n);
    for(int i = 0; i < n; i++){
        for(int j: b[i]){
            chmax(dp[i], dp[j]+a[i]-a[j]);
        }
        if(i != 0) chmax(dp[i], dp[i-1]);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}
0