結果

問題 No.1676 Coin Trade (Single)
ユーザー SSRSSSRS
提出日時 2021-09-10 21:33:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 171,088 KB
実行使用メモリ 9,460 KB
最終ジャッジ日時 2023-09-02 16:06:16
合計ジャッジ時間 5,398 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 68 ms
7,532 KB
testcase_04 AC 62 ms
6,920 KB
testcase_05 AC 57 ms
6,416 KB
testcase_06 AC 57 ms
6,492 KB
testcase_07 AC 48 ms
5,700 KB
testcase_08 AC 32 ms
4,380 KB
testcase_09 AC 48 ms
5,760 KB
testcase_10 AC 50 ms
6,048 KB
testcase_11 AC 71 ms
8,032 KB
testcase_12 AC 40 ms
4,932 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 89 ms
9,304 KB
testcase_34 AC 90 ms
9,460 KB
testcase_35 AC 90 ms
9,360 KB
testcase_36 AC 89 ms
9,348 KB
testcase_37 AC 90 ms
9,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000;
int main(){
  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] = vector<int>(M[i]);
    for (int j = 0; j < M[i]; j++){
      cin >> B[i][j];
      B[i][j]--;
    }
  }
  vector<long long> dp(N, 0);
  vector<long long> mx(N, 0);
  for (int i = 1; i < N; i++){
    for (int j = 0; j < M[i]; j++){
      dp[i] = max(dp[i], mx[B[i][j]] + A[i] - A[B[i][j]]);
    }
    mx[i] = max(mx[i - 1], dp[i]);
  }
  cout << mx[N - 1] << endl;
}
0