結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-18 02:09:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 894 ms |
| コンパイル使用メモリ | 72,516 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:37:25 |
| 合計ジャッジ時間 | 1,761 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int T;
main()
{
cin>>T;
for(;T--;)
{
long A[3];
for(int i=0;i<3;i++)cin>>A[i];
long ans=9e18;
vector<int>id={0,1,2};
do{
if(id[1]==1)continue;
long a=A[id[0]],b=A[id[1]],c=A[id[2]];
long now=0;
if(b>=c)
{
now+=b-c+1;
b=c-1;
}
if(a>=b)
{
now+=a-b+1;
a=b-1;
}
if(a<=0)continue;
ans=min(ans,now);
}while(next_permutation(id.begin(),id.end()));
if(ans>=1e18)ans=-1;
cout<<ans<<endl;
}
}