結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-13 21:42:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 678 bytes |
| コンパイル時間 | 1,512 ms |
| コンパイル使用メモリ | 160,124 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-23 00:01:57 |
| 合計ジャッジ時間 | 1,958 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
int solve(int a, int b, int c){
int ans = 0;
if(a <= b){
if(a == 1) return LLONG_MAX;
ans += b-(a-1);
b = a-1;
}
if(b <= c){
if(b == 1) return LLONG_MAX;
ans += c-(b-1);
}
return ans;
}
signed main(){
int t;
cin >> t;
for(int i = 0;i < t;i++){
int a, b, c;
cin >> a >> b >> c;
int ans = min({solve(b, a, c), solve(b, c, a), solve(a, c, b), solve(c, a, b)});
if(ans == LLONG_MAX){
cout << -1 << endl;
}else{
cout << ans << endl;
}
}
return 0;
}