結果

問題 No.1676 Coin Trade (Single)
ユーザー masutech16masutech16
提出日時 2021-09-10 22:14:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,998 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 204,560 KB
実行使用メモリ 9,456 KB
最終ジャッジ日時 2023-09-02 18:10:34
合計ジャッジ時間 4,548 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 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 AC 24 ms
5,948 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,372 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,368 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,368 KB
testcase_21 AC 1 ms
4,368 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,368 KB
testcase_24 AC 1 ms
4,368 KB
testcase_25 AC 2 ms
4,372 KB
testcase_26 AC 2 ms
4,372 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
4,372 KB
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 1 ms
4,368 KB
testcase_32 AC 1 ms
4,368 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 37 ms
9,352 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/Assert/Assert.hpp"
#include <cassert>
#include <iostream>
#include <string>
#ifndef MY_ASSERT
#define MY_ASSERT

#ifdef LOCAL

#define ASSERT_MSG(expr, msg)                                                                                          \
  do {                                                                                                                 \
    if (!(expr)) {                                                                                                     \
      std::cerr << msg << std::endl;                                                                                   \
      assert(expr);                                                                                                    \
    }                                                                                                                  \
  } while (0)

#define FAIL ASSERT_MSG(false, "到達しない想定の場所に到達しました")

#else

#define ASSERT_MSG(...) (void)0
#define FAIL (void)0

#endif

#endif
#line 2 "/workspaces/compro/lib/io/vector.hpp"
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 5 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define RREP(i, n) for (int i = (n - 1); i >= 0; i--)
#define RFOR(i, m, n) for (int i = (n - 1); i >= (m); i--)
#define ALL(v) std::begin(v), std::end(v)
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

struct P {
  ll x;
  ll y;
};

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

// generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, K;
  cin >> N >> K;
  vl A(N);
  vi M(N);
  vector<vl> B(N);
  REP(i, N) {
    cin >> A[i] >> M[i];
    REP(j, M[i]) {
      ll b;
      cin >> b;
      B[i].push_back(b);
    }
  }

  vector<ll> dp(N + 1, 0);
  REP(i, N) {
    dp[i + 1] = dp[i];
    REP(j, M[i]) { chmax(dp[i + 1], A[i] - A[B[i][j] - 1] + dp[B[i][j] - 1]); }
  }
  cout << dp[N] << endl;
}
0