結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-13 22:02:21 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 1,074 ms |
| コンパイル使用メモリ | 138,864 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 16:04:29 |
| 合計ジャッジ時間 | 1,473 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 3 |
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <climits>
using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
typedef long long int64;
int main() {
int t;
cin >> t;
for (int i=0; i<t; i++) {
int a,b,c;
int ans = INT_MAX;
cin >> a >> b >> c;
if ((a<b&&c<b) || (b<a&&b<c)) {
cout << 0 << endl;
continue;
}
if (a == b && b == c && a >= 3) {
cout << 3 << endl;
continue;
}
if (a > c) swap(a,c);
if (a == 1 && b == 2) {
cout << -1 << endl;
continue;
}
if (a != 1) {
ans = min(ans, abs(b-a) + 1);
}
ans = min(ans, abs(b-c) + 1 + (b-1==a? 1 : 0));
cout << ans << endl;
}
}