結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2020-01-13 20:48:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 994 bytes |
| コンパイル時間 | 701 ms |
| コンパイル使用メモリ | 73,836 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-21 16:47:57 |
| 合計ジャッジ時間 | 1,190 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int f(int a, int b, int c) {
int x = 0;
if (a >= b) x += a - (b - 1), a = b - 1;
if (c >= b) x += c - (b - 1), c = b - 1;
if (a == c) x++, a--;
if (a <= 0 || c <= 0) x = -1;
return x;
}
int g(int a, int b, int c) {
int x = 0;
if (a == c) x++, a--;
int t = min(a, c);
if (b >= t) x += b - (t - 1), b = t - 1;
if (a <= 0 || b <= 0) x = -1;
return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int a, b, c;
cin >> a >> b >> c;
int x = f(a, b, c);
int y = g(a, b, c);
int r;
if (x < 0 && y < 0) r = -1;
else if (x < 0) r = y;
else if (y < 0) r = x;
else r = min(x, y);
cout << r << '\n';
}
return 0;
}
merom686