結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー Shun_PIShun_PI
提出日時 2022-10-15 00:51:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,535 bytes
コンパイル時間 2,805 ms
コンパイル使用メモリ 186,964 KB
実行使用メモリ 599,460 KB
最終ジャッジ日時 2023-09-09 01:30:37
合計ジャッジ時間 37,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 185 ms
315,748 KB
testcase_01 AC 139 ms
315,492 KB
testcase_02 AC 119 ms
315,484 KB
testcase_03 AC 994 ms
315,632 KB
testcase_04 AC 1,855 ms
315,492 KB
testcase_05 AC 95 ms
315,416 KB
testcase_06 AC 980 ms
315,544 KB
testcase_07 AC 984 ms
315,484 KB
testcase_08 AC 139 ms
321,008 KB
testcase_09 AC 126 ms
319,312 KB
testcase_10 AC 198 ms
327,832 KB
testcase_11 AC 207 ms
328,380 KB
testcase_12 AC 132 ms
317,912 KB
testcase_13 AC 985 ms
315,476 KB
testcase_14 AC 1,859 ms
315,468 KB
testcase_15 AC 95 ms
315,544 KB
testcase_16 AC 975 ms
315,372 KB
testcase_17 AC 985 ms
315,412 KB
testcase_18 AC 303 ms
329,560 KB
testcase_19 AC 351 ms
320,232 KB
testcase_20 AC 228 ms
326,556 KB
testcase_21 AC 128 ms
319,656 KB
testcase_22 AC 120 ms
318,636 KB
testcase_23 AC 133 ms
320,120 KB
testcase_24 AC 456 ms
320,224 KB
testcase_25 AC 127 ms
319,624 KB
testcase_26 AC 137 ms
320,748 KB
testcase_27 AC 108 ms
317,656 KB
testcase_28 AC 983 ms
315,496 KB
testcase_29 AC 1,861 ms
315,416 KB
testcase_30 AC 97 ms
315,416 KB
testcase_31 AC 984 ms
315,548 KB
testcase_32 AC 987 ms
315,532 KB
testcase_33 AC 984 ms
315,416 KB
testcase_34 AC 1,854 ms
315,548 KB
testcase_35 AC 96 ms
315,540 KB
testcase_36 AC 982 ms
315,540 KB
testcase_37 AC 984 ms
315,480 KB
testcase_38 AC 150 ms
321,228 KB
testcase_39 AC 168 ms
321,424 KB
testcase_40 AC 148 ms
322,288 KB
testcase_41 AC 167 ms
321,024 KB
testcase_42 AC 164 ms
324,128 KB
testcase_43 AC 120 ms
318,836 KB
testcase_44 AC 101 ms
316,596 KB
testcase_45 AC 202 ms
323,548 KB
testcase_46 AC 158 ms
322,616 KB
testcase_47 AC 146 ms
319,224 KB
testcase_48 AC 986 ms
315,600 KB
testcase_49 AC 1,861 ms
315,492 KB
testcase_50 AC 96 ms
315,612 KB
testcase_51 AC 979 ms
315,596 KB
testcase_52 AC 984 ms
315,608 KB
testcase_53 MLE -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint T, X, A, Y, B;
  cin >> T >> X >> A >> Y >> B;
  vector<lint> dp(40000001, 1e18);
  dp[20000000] = 0;
  set<PL> st;
  st.insert(PL(0, 20000000));
  lint ans = 1e18;
  while(!st.empty()) {
    PL p = *st.begin();
    st.erase(p);
    lint x = p.second;
    if(x <= 20000000+T) chmin(ans, dp[x] + abs(20000000+T-x));
    if(dp[x] > ans) break;
    if(x+A < 40000001 && dp[x] + X < dp[x+A]) {
      dp[x+A] = dp[x] + X;
      st.insert(PL(dp[x+A], x+A));
    }
    if(x-B >= 0 && dp[x] + Y < dp[x-B]) {
      dp[x-B] = dp[x] + Y;
      st.insert(PL(dp[x-B], x-B));
    }
  }
  cout << ans << endl;
}
0