結果
| 問題 |
No.1486 ロボット
|
| コンテスト | |
| ユーザー |
tarattata1
|
| 提出日時 | 2020-04-19 09:02:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,012 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 31,488 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 09:41:18 |
| 合計ジャッジ時間 | 880 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <cstdio>
#define MIN(a, b) ((a)>(b)? (b): (a))
using namespace std;
int calc(int a, int b, int c, int d, int e)
{
int cnt = 0;
int i;
for (i = 0; i < e; i += (a + b)) {
int t_stt = i;
int t_end = MIN(i + a, e);
// t_stt <= t < t_end の範囲について、
// ロボット1は必ず動いている。ロボット2が動いているのが何秒間かを求める
int t_stt_r = t_stt % (c + d);
int tmp = t_end - (t_stt - t_stt_r);
int cnt0 = tmp / (c + d) * c;
int cnt1 = MIN(tmp % (c + d), c);
int cnttmp = cnt0 + cnt1 - MIN(t_stt_r, c);
cnt += cnttmp;
}
return cnt;
}
int main()
{
int a, b, c, d, e;
scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
int lim = (a + b)*(c + d);
int ans = 0;
if (e > lim) {
int ans0 = calc(a, b, c, d, lim);
ans += ans0 * (e / lim);
e %= lim;
}
ans += calc(a, b, c, d, e);
printf("%d\n", ans);
return 0;
}
tarattata1