結果
問題 | No.966 引き算をして門松列(その1) |
ユーザー |
![]() |
提出日時 | 2020-03-06 09:07:15 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,533 bytes |
コンパイル時間 | 4,551 ms |
コンパイル使用メモリ | 77,216 KB |
実行使用メモリ | 48,020 KB |
最終ジャッジ日時 | 2024-10-14 02:39:01 |
合計ジャッジ時間 | 4,876 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | WA * 5 |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author silviase */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); Kadomatsu solver = new Kadomatsu(); solver.solve(1, in, out); out.close(); } static class Kadomatsu { public void solve(int testNumber, Scanner in, PrintWriter out) { // int q = in.nextInt(); for (int i = 0; i < q; i++) { out.println(query(in.nextInt(), in.nextInt(), in.nextInt())); } } private long query(int a, int b, int c) { long res = (long) 1e11; if (b < 3 && Math.min(a, c) == 1) { return -1; } int tmp = 0; if (a == c) { ++tmp; --c; } if (Math.min(a, c) >= 2) { res = Math.min(res, /* b が 最小になる*/ Math.max(0, tmp + b - Math.min(a, c) + 1)); } if (b >= 3) { res = Math.min(res, /* b が 最大になる*/ Math.max(0, tmp + a - b + 1 + c - b + 2)); } return res; } } }