結果

問題 No.974 最後の日までに
ユーザー Ryuhei MoriRyuhei Mori
提出日時 2020-01-18 00:56:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,418 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 59,580 KB
実行使用メモリ 570,664 KB
最終ジャッジ日時 2024-04-14 21:52:43
合計ジャッジ時間 5,893 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 6 ms
6,816 KB
testcase_02 AC 6 ms
6,940 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 3 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 3 ms
6,948 KB
testcase_37 AC 3 ms
6,940 KB
testcase_38 AC 3 ms
6,944 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,944 KB
testcase_43 AC 3 ms
6,940 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 2 ms
6,940 KB
testcase_46 AC 2 ms
6,944 KB
testcase_47 AC 2 ms
6,940 KB
testcase_48 AC 3 ms
6,940 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 AC 3 ms
6,940 KB
testcase_51 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>

int w;
long long int A[100], B[100], C[100];

struct S {
  long long int money;
  long long int love;
};

std::vector<S> states0, states1, tmp;

int main(){
  scanf("%d", &w);
  for(int i = 0; i < w; i++) scanf("%lld%lld%lld", A+i, B+i, C+i);

  states0.emplace_back(S({0, 0}));
  for(int i = 0; i < w; i++){
    for(auto it0 = states0.begin(), it1 = states1.begin(); ;){
      if(it0 == states0.end()){ for(; it1 != states1.end(); ++it1){ tmp.emplace_back(S({it1->money - C[i], it1->love + B[i]})); } break;}
      else if(it1 == states1.end()){ for(; it0 != states0.end(); ++it0){ tmp.emplace_back(S({it0->money + A[i], it0->love})); } break;}
      else if(it0->money + A[i] >= it1->money - C[i] && it0->love >= it1->love + B[i]) ++it1;
      else if(it0->money + A[i] <= it1->money - C[i] && it0->love <= it1->love + B[i]) ++it0;
      else if(it0->money + A[i] <= it1->money - C[i]) tmp.emplace_back(S({it0->money + A[i], it0->love})), ++it0;
      else tmp.emplace_back(S({it1->money - C[i], it1->love + B[i]})), ++it1;
    }
    states0.swap(states1);
    states0.swap(tmp);
    tmp.clear();
/*
for(auto &s: states0) printf("(%lld %lld) ", s.money, s.love);
puts("");
std::fflush(stdout);
*/
  }

  long long int ans = 0;
  for(auto &s: states0){
    if(s.money >= 0){
      ans = s.love;
      break;
    }
  }

  printf("%lld\n", ans);

  return 0;
}
0