結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー Shun_PIShun_PI
提出日時 2022-10-15 00:52:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,535 bytes
コンパイル時間 2,410 ms
コンパイル使用メモリ 188,908 KB
実行使用メモリ 458,668 KB
最終ジャッジ日時 2023-09-09 01:31:18
合計ジャッジ時間 25,670 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
163,696 KB
testcase_01 AC 40 ms
159,380 KB
testcase_02 AC 42 ms
159,312 KB
testcase_03 AC 931 ms
159,264 KB
testcase_04 AC 1,108 ms
159,188 KB
testcase_05 AC 40 ms
159,228 KB
testcase_06 AC 537 ms
159,224 KB
testcase_07 AC 536 ms
159,312 KB
testcase_08 AC 83 ms
164,464 KB
testcase_09 AC 69 ms
162,884 KB
testcase_10 AC 145 ms
171,588 KB
testcase_11 AC 93 ms
165,772 KB
testcase_12 AC 66 ms
160,632 KB
testcase_13 AC 933 ms
159,180 KB
testcase_14 AC 1,102 ms
159,312 KB
testcase_15 AC 41 ms
159,176 KB
testcase_16 AC 534 ms
159,192 KB
testcase_17 AC 538 ms
159,272 KB
testcase_18 AC 189 ms
166,480 KB
testcase_19 AC 191 ms
162,412 KB
testcase_20 AC 129 ms
163,416 KB
testcase_21 AC 73 ms
163,404 KB
testcase_22 AC 63 ms
162,032 KB
testcase_23 AC 79 ms
163,996 KB
testcase_24 AC 255 ms
161,556 KB
testcase_25 AC 71 ms
163,468 KB
testcase_26 AC 81 ms
164,084 KB
testcase_27 AC 55 ms
161,416 KB
testcase_28 AC 932 ms
159,316 KB
testcase_29 AC 1,098 ms
159,240 KB
testcase_30 AC 42 ms
159,308 KB
testcase_31 AC 534 ms
159,292 KB
testcase_32 AC 534 ms
159,300 KB
testcase_33 AC 929 ms
159,192 KB
testcase_34 AC 1,101 ms
159,280 KB
testcase_35 AC 40 ms
159,312 KB
testcase_36 AC 535 ms
159,308 KB
testcase_37 AC 536 ms
159,436 KB
testcase_38 AC 85 ms
163,000 KB
testcase_39 AC 112 ms
165,372 KB
testcase_40 AC 94 ms
166,172 KB
testcase_41 AC 110 ms
164,704 KB
testcase_42 AC 111 ms
168,020 KB
testcase_43 AC 64 ms
162,872 KB
testcase_44 AC 48 ms
160,240 KB
testcase_45 AC 115 ms
164,196 KB
testcase_46 AC 97 ms
165,340 KB
testcase_47 AC 87 ms
162,356 KB
testcase_48 AC 929 ms
159,224 KB
testcase_49 AC 1,105 ms
159,236 KB
testcase_50 AC 41 ms
159,404 KB
testcase_51 AC 535 ms
159,308 KB
testcase_52 AC 534 ms
159,436 KB
testcase_53 TLE -
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(20000001, 1e18);
  dp[10000000] = 0;
  set<PL> st;
  st.insert(PL(0, 10000000));
  lint ans = 1e18;
  while(!st.empty()) {
    PL p = *st.begin();
    st.erase(p);
    lint x = p.second;
    if(x <= 10000000+T) chmin(ans, dp[x] + abs(10000000+T-x));
    if(dp[x] > ans) break;
    if(x+A < 20000001 && 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