結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー kuraraberukuraraberu
提出日時 2022-10-14 22:25:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 163,352 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-08 22:32:04
合計ジャッジ時間 4,232 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,388 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 1 ms
4,384 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 1 ms
4,384 KB
testcase_41 WA -
testcase_42 AC 2 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,384 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 1 ms
4,384 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
4,384 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,384 KB
testcase_60 AC 1 ms
4,384 KB
testcase_61 AC 2 ms
4,384 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

template<typename T>bool chmax(T &a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a, const T& b){if(a>b){a=b;return true;}return false;}

int main(){
    int t;cin>>t;
    int x,a;cin>>x>>a;
    int y,b;cin>>y>>b;
    if(t<0){
        // t=-t;
        swap(x,y);
        swap(a,b);
    }
    if(t>0){
        int w=t/a;
        int ama=t%a;
        if(ama==0){
            cout<<x*w<<endl;
            return 0;
        }
        else{
            // int ne=w+1;
            int mae=x*w+t%a;
            // cout<<mae<<endl;
            int ushiro=x*(t+b)/a+y+(t+b)%a;
            // cout<<ushiro<<endl;
            cout<<min(mae,ushiro)<<endl;
            return 0;
        }
    }
    else{
        t=-t;
        int w=t/a;
        int ama=t%a;
        if(ama==0){
            cout<<x*w<<endl;
            return 0;
        }
        else{
            int ne=w+1;
            int mae=x*ne+(ne*a)-t;
            // cout<<mae<<endl;
            int ushiro=x*(t+b)/a+y+(t+b)%a;
            // cout<<ushiro<<endl;
            cout<<min(mae,ushiro)<<endl;
            return 0;
        }
    }
    
}
0