結果
| 問題 |
No.3173 じゃんけんの勝ちの回数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-06 22:04:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 1,612 bytes |
| コンパイル時間 | 2,027 ms |
| コンパイル使用メモリ | 198,560 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-06-06 22:04:48 |
| 合計ジャッジ時間 | 3,692 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i32 = int;
using i64 = long long;
using f64 = long double;
using i128 = __int128_t;
using p2 = pair<i64, i64>;
using el = tuple<i64, i64, i64>;
// using mint = atcoder::modint998244353;
void _main();
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
_main();
}
i64 pow(i64 x, i64 n) {
i64 res = 1;
i64 t = x;
while (n > 0) {
if (n & 1) {
res = res * t;
}
t = t * t;
}
return res;
}
void _main() {
i64 t;
cin >> t;
for (;t--;) {
vector<i64> a(3), b(3);
for (i64 i = 0; i < 3; i++) cin >> a[i];
for (i64 i = 0; i < 3; i++) cin >> b[i];
i64 mx = 0, mn = 1e18;
for (i64 i = 0; i < 3; i++) {
mx += min(a[i], b[(i + 1) % 3]);
}
for (i64 i = 0; i < 3; i++) {
for (i64 j = 0; j < 3; j++) {
i64 ci = i, cj = j;
i64 x = 0, y = 0;
i64 cnt = 0;
while (ci < i + 3 || cj < j + 3) {
if (x == y) {
if ((ci + 1) % 3 == cj % 3) {
cnt += min(a[ci % 3], b[cj % 3]);
}
x += a[ci % 3], y += b[cj % 3];
ci++, cj++;
} else if (x < y) {
if ((ci + 1) % 3 == (cj + 2) % 3) {
cnt += min(a[ci % 3], y - x);
}
x += a[ci % 3];
ci++;
} else {
if ((ci + 1 + 2) % 3 == cj % 3) {
cnt += min(b[cj % 3], x - y);
}
y += b[cj % 3];
cj++;
}
}
mx = max(mx, cnt), mn = min(mn, cnt);
}
}
cout << mn << " " << mx << "\n";
}
}