結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
toof
|
| 提出日時 | 2020-01-13 22:13:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,400 bytes |
| コンパイル時間 | 2,027 ms |
| コンパイル使用メモリ | 196,508 KB |
| 最終ジャッジ日時 | 2025-01-08 17:48:19 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }
int main() {
cin.tie(0); ios::sync_with_stdio(false);
ll n;
cin >> n;
vl a(n), b(n), c(n);
rep(i, n) {
cin >> a[i] >> b[i] >> c[i];
}
constexpr ll inf = 1LL << 60;
rep(i, n) {
ll s = 0;
ll t = 0;
[&s](ll a, ll b, ll c) {
if (b < 3) {
s = inf;
return;
}
if (a >= b) {
s += a-(b-1);
a = b-1;
}
if (c >= b) {
s += c-(b-1);
c = b-1;
}
if (a == c) {
s++;
}
}(a[i], b[i], c[i]);
[&t](ll a, ll b, ll c) {
if (min(a, c) < 2 or (c <= 2 and a <= 2)) {
t = inf;
return;
}
if (b >= min(a, c)) {
t += b-(min(a, c)-1);
b = min(a, c)-1;
}
if (a == c) {
t++;
if (b+1 == a) t++;
}
}(a[i], b[i], c[i]);
//cerr << s << " " << t << endl;
if (s == inf and t == inf) {
cout << -1 << endl;
} else {
cout << min(s, t) << endl;
}
}
}
toof