結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー milanis48663220milanis48663220
提出日時 2022-10-14 21:37:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 2,029 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 114,272 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 20:28:13
合計ジャッジ時間 10,971 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 228 ms
4,380 KB
testcase_06 AC 118 ms
4,376 KB
testcase_07 AC 64 ms
4,376 KB
testcase_08 AC 106 ms
4,376 KB
testcase_09 AC 93 ms
4,376 KB
testcase_10 AC 111 ms
4,380 KB
testcase_11 AC 112 ms
4,380 KB
testcase_12 AC 53 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 228 ms
4,376 KB
testcase_16 AC 118 ms
4,380 KB
testcase_17 AC 65 ms
4,376 KB
testcase_18 AC 79 ms
4,380 KB
testcase_19 AC 77 ms
4,376 KB
testcase_20 AC 74 ms
4,376 KB
testcase_21 AC 66 ms
4,380 KB
testcase_22 AC 107 ms
4,380 KB
testcase_23 AC 49 ms
4,384 KB
testcase_24 AC 104 ms
4,380 KB
testcase_25 AC 57 ms
4,380 KB
testcase_26 AC 80 ms
4,384 KB
testcase_27 AC 44 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 228 ms
4,380 KB
testcase_31 AC 117 ms
4,384 KB
testcase_32 AC 64 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 228 ms
4,380 KB
testcase_36 AC 118 ms
4,380 KB
testcase_37 AC 65 ms
4,380 KB
testcase_38 AC 75 ms
4,380 KB
testcase_39 AC 35 ms
4,380 KB
testcase_40 AC 70 ms
4,380 KB
testcase_41 AC 23 ms
4,376 KB
testcase_42 AC 88 ms
4,380 KB
testcase_43 AC 84 ms
4,380 KB
testcase_44 AC 86 ms
4,380 KB
testcase_45 AC 75 ms
4,380 KB
testcase_46 AC 70 ms
4,380 KB
testcase_47 AC 37 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 229 ms
4,384 KB
testcase_51 AC 122 ms
4,376 KB
testcase_52 AC 65 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 78 ms
4,380 KB
testcase_56 AC 229 ms
4,376 KB
testcase_57 AC 228 ms
4,376 KB
testcase_58 AC 229 ms
4,376 KB
testcase_59 AC 229 ms
4,376 KB
testcase_60 AC 229 ms
4,380 KB
testcase_61 AC 229 ms
4,376 KB
testcase_62 AC 228 ms
4,380 KB
testcase_63 AC 229 ms
4,380 KB
testcase_64 AC 229 ms
4,380 KB
testcase_65 AC 230 ms
4,376 KB
testcase_66 AC 229 ms
4,376 KB
testcase_67 AC 228 ms
4,384 KB
testcase_68 AC 229 ms
4,380 KB
testcase_69 AC 228 ms
4,380 KB
testcase_70 AC 229 ms
4,384 KB
testcase_71 AC 229 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

// calc ceil(a/b) 
template<typename T>
T ceil_div(T a, T b){
    return (a+b-1)/b;
}

const ll inf = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll t, x, a, y, b; cin >> t >> x >> a >> y >> b;
    ll ans = inf;
    for(ll p = 0; p < b; p++){
        ll tt = p*a;
        ll tmp = p*x;
        if(tt >= t){
            ll dist = tt-t;
            ll c = ceil_div(dist, b);
            tmp += c*y + (c*b-dist);
        }else{
            tmp += t-tt;
        }
        chmin(ans, tmp);
    }

    for(ll q = 0; q < a; q++){
        ll tt = -q*b;
        ll tmp = q*y;
        if(tt <= t){
            ll dist = t-tt;
            ll c = dist/a;
            tmp += c*x + (dist-c*a);
        }else{
            continue;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}
0