結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-01-16 12:32:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 1,119 bytes |
| コンパイル時間 | 793 ms |
| コンパイル使用メモリ | 93,128 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 15:09:22 |
| 合計ジャッジ時間 | 1,250 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 966.cc: No.966 引き算をして門松列(その1) - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int INF = 1 << 30;
/* typedef */
/* global variables */
/* subroutines */
int check(int p, int q, int r) {
int s = 0;
int d0 = q - r + 1;
if (d0 > 0) q -= d0, s += d0;
int d1 = p - q + 1;
if (d1 > 0) p -= d1, s += d1;
return (p < 1) ? INF : s;
}
inline void setmin(int &a, int b) { if (a > b) a = b; }
/* main */
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int mind = INF;
setmin(mind, check(a, c, b));
setmin(mind, check(c, a, b));
setmin(mind, check(b, a, c));
setmin(mind, check(b, c, a));
printf("%d\n", (mind >= INF) ? -1 : mind);
}
return 0;
}
tnakao0123