結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
tempura_pp
|
| 提出日時 | 2020-01-13 20:33:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,036 bytes |
| コンパイル時間 | 1,075 ms |
| コンパイル使用メモリ | 96,428 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-21 16:20:37 |
| 合計ジャッジ時間 | 1,614 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
void solve(){
ll a,b,c;
cin>>a>>b>>c;
ll target[]={a-1,a,b-2,b-1,b,b+1,b+2,c-1,c};
ll ans = longinf;
rep(i,9)rep(j,9)rep(k,9){
ll x = target[i],y=target[j],z=target[k];
if(x>a||y>b||z>c)continue;
if(x<=0 ||y<= 0||z<=0)continue;
if(x==y||y==z||z==x)continue;
if(y>x && y>z) ans = min(ans,a-x+b-y+c-z);
if(y<x && y<z) ans = min(ans,a-x+b-y+c-z);
}
if(ans == longinf)cout<<-1<<endl;
else cout<<ans<<endl;
}
int main(){
int t;
cin>>t;
rep(i,t)solve();
return 0;
}
tempura_pp