結果

問題 No.1676 Coin Trade (Single)
ユーザー milanis48663220milanis48663220
提出日時 2021-09-10 22:05:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,285 bytes
コンパイル時間 1,332 ms
コンパイル使用メモリ 121,544 KB
実行使用メモリ 8,324 KB
最終ジャッジ日時 2023-09-02 17:49:05
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,368 KB
testcase_14 AC 1 ms
4,368 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,492 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 1 ms
4,368 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,368 KB
testcase_21 AC 2 ms
4,372 KB
testcase_22 AC 2 ms
4,372 KB
testcase_23 AC 1 ms
4,372 KB
testcase_24 AC 2 ms
4,372 KB
testcase_25 AC 1 ms
4,372 KB
testcase_26 AC 1 ms
4,368 KB
testcase_27 AC 1 ms
4,372 KB
testcase_28 AC 1 ms
4,368 KB
testcase_29 AC 1 ms
4,372 KB
testcase_30 AC 1 ms
4,372 KB
testcase_31 AC 2 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

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<int> 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