結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-01-13 20:29:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 795 bytes |
| コンパイル時間 | 2,071 ms |
| コンパイル使用メモリ | 193,120 KB |
| 最終ジャッジ日時 | 2025-01-08 17:30:18 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 3 WA * 2 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
const Int INF = 1e18;
Int p1(Int a,Int b,Int c){
// a < b > c
Int res=0;
if(a>=b) res+=a-b+1,a=b-1;
if(c>=b) res+=c-b+1,c=b-1;
if(a==c) a--,res++;
return res;
}
Int p2(Int a,Int b,Int c){
Int res=0;
if(a==c) a--,res++;
if(b>=min(a,c))
res+=b-min(a,c)+1,b=min(a,c)-1;
if(min({a,b,c})<=0) return INF;
return res;
}
signed solve(){
Int a,b,c;
cin>>a>>b>>c;
Int ans=min(p1(a,b,c),p2(a,b,c));
if(ans==INF) ans=-1;
cout<<ans<<endl;
return 0;
}
signed main(){
Int T;
cin>>T;
while(T--) solve();
return 0;
}
beet