結果
問題 | No.968 引き算をして門松列(その3) |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2022-04-20 23:57:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 356 ms / 2,000 ms |
コード長 | 1,184 bytes |
コンパイル時間 | 296 ms |
コンパイル使用メモリ | 87,076 KB |
実行使用メモリ | 82,164 KB |
最終ジャッジ日時 | 2023-09-02 20:30:50 |
合計ジャッジ時間 | 4,170 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
71,364 KB |
testcase_01 | AC | 74 ms
71,228 KB |
testcase_02 | AC | 76 ms
71,452 KB |
testcase_03 | AC | 288 ms
78,920 KB |
testcase_04 | AC | 263 ms
80,184 KB |
testcase_05 | AC | 259 ms
80,016 KB |
testcase_06 | AC | 260 ms
80,164 KB |
testcase_07 | AC | 236 ms
79,488 KB |
testcase_08 | AC | 288 ms
79,904 KB |
testcase_09 | AC | 337 ms
82,164 KB |
testcase_10 | AC | 346 ms
81,960 KB |
testcase_11 | AC | 356 ms
81,008 KB |
ソースコード
inf = 10**30 # b > c > a def calc1(a,b,c,x,y,z): l = [a,b,c] count = [0,0,0] count2 = [0,0,0] if a >= c: count[2] += (a-c+1)*z count2[2] += a-c+1 c = a+1 if c >= b: count[1] += (c-b+1)*y count2[1] += c-b+1 b = c+1 for i in range(3): for j in range(3): if i == j: continue l[j] -= count2[i] if min(l) > 0: return sum(count) return inf # c > a > b def calc2(a,b,c,x,y,z): l = [a,b,c] count = [0,0,0] count2 = [0,0,0] if b >= a: count[0] += (b-a+1)*x count2[0] += b-a+1 a = b+1 if a >= c: count[2] += (a-c+1)*z count2[2] += a-c+1 c = a+1 for i in range(3): for j in range(3): if i == j: continue l[j] -= count2[i] if min(l) > 0: return sum(count) return inf t = int(input()) for _ in range(t): a,b,c,x,y,z = map(int,input().split()) x,y,z = y,z,x ans = min(calc1(a,b,c,x,y,z),calc2(a,b,c,x,y,z),calc1(c,b,a,z,y,x),calc2(c,b,a,z,y,x)) if ans == inf: ans = -1 print(ans)