結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー Shun_PI
提出日時 2022-10-15 00:51:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,535 bytes
コンパイル時間 2,469 ms
コンパイル使用メモリ 190,152 KB
実行使用メモリ 628,052 KB
最終ジャッジ日時 2024-06-26 18:48:12
合計ジャッジ時間 34,569 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 53 MLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0