結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー TaniiGoTaniiGo
提出日時 2022-10-14 22:19:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,319 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 197,760 KB
実行使用メモリ 5,120 KB
最終ジャッジ日時 2023-09-08 22:14:25
合計ジャッジ時間 4,498 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,996 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,500 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,384 KB
testcase_42 AC 1 ms
4,508 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 1 ms
4,504 KB
testcase_51 AC 1 ms
4,384 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 1 ms
4,376 KB
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;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define all(a) begin(a), end(a)
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

ll modpow(ll a, ll b, ll m) {
	ll p = a;
	ll ans = 1;
	rep(i,32) {
		if ((b & (0x01 << i)) != 0) {
			ans *= p;
			ans %= m;
		}
		p *= p;
		p %= m;
	}
	return (ans);
}

ll pow(ll a, ll b) {
	ll p = a;
	ll ans = 1;
	rep(i,32) {
		if ((b & (0x01 << i)) != 0) {
			ans *= p;
		}
		p *= p;
	}
	return (ans);
}

ll Division(ll a, ll b, ll m) {
	return ((a * modpow(b, m - 2, m)) % m);
}

struct V {
	int x, y;
	V(int x=0, int y=0): x(x), y(y) {}
	V operator-(const V &a) const {
		return V(x-a.x, y-a.y);
	}
	int cross(const V &a) const {
		return x*a.y - y*a.x;
	}
	int ccw(const V &a) const {
		int area = cross(a);
		if (area > 0) return +1; // ccw
		if (area < 0) return -1; // cw
		return 0; // collinear
	}
};

/*
	2147483648 int max
	1000000000 1e9
	9223372036854775807 ll max
	1000000000000000000 1e18
*/

int main() {
	int t;
	cin >> t;
	int x, a, y, b;
	cin >> x >> a >> y >> b;

	if (t > 0) {
		int now = 0;
		int c0 = (t-now)/a*x;
		c0 += t%a;

		now = 0;
		int c1 = ((t+a-1)/a)*x;
		now = (t+a-1)/a*a;
		c1 += (now-t+b-1)/b*y;
		now -= (now-t+b-1)/b*b;
		c1 += (t-now);

		now = 0;
		int c2 = (t+a+b-1)/a*x;
		now = (t+a+b-1)/a*a;
		c2 += (now-t+b-1)/b*y;
		now -= (now-t+b-1)/b*b;
		c2 += t-now;
		chmin(c0,c1);
		chmin(c0,c2);
		cout << c0 << endl;
	}
	else {
		t = -t;
		int now = 0;
		int c0 = (t-now+b-1)/b*y;
		now = (t-now+b-1)/b*b;
		c0 += (now-t)/a*x;
		now -= (now-t)/a*a;
		c0 += abs(t-now);

		now = 0;
		int c1 = (t-now+a+b-1)/b*y;
		now = (t-now+a+b-1)/b*b;
		c1 += (abs(t-now)/a)*x;
		now -= (abs(t-now)/a)*a;
		c1 += abs(t-now);
		cout << min(c0, c1) << endl;
	}
	return 0;
}
0