結果

問題 No.994 ばらばらコイン
ユーザー kekenxkekenx
提出日時 2020-04-02 21:38:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 448 bytes
コンパイル時間 1,438 ms
コンパイル使用メモリ 166,572 KB
実行使用メモリ 9,044 KB
最終ジャッジ日時 2023-09-11 00:47:19
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,700 KB
testcase_01 AC 3 ms
5,704 KB
testcase_02 AC 65 ms
8,884 KB
testcase_03 AC 74 ms
8,996 KB
testcase_04 AC 74 ms
8,932 KB
testcase_05 AC 37 ms
7,316 KB
testcase_06 AC 74 ms
9,044 KB
testcase_07 AC 74 ms
8,936 KB
testcase_08 AC 50 ms
7,912 KB
testcase_09 AC 69 ms
8,724 KB
testcase_10 AC 51 ms
8,000 KB
testcase_11 AC 59 ms
8,228 KB
testcase_12 AC 62 ms
8,444 KB
testcase_13 AC 3 ms
5,692 KB
testcase_14 AC 3 ms
5,700 KB
testcase_15 AC 3 ms
5,704 KB
testcase_16 AC 3 ms
5,688 KB
testcase_17 AC 4 ms
5,972 KB
testcase_18 AC 3 ms
6,020 KB
testcase_19 AC 3 ms
5,692 KB
testcase_20 AC 3 ms
5,744 KB
testcase_21 AC 3 ms
5,816 KB
testcase_22 AC 4 ms
5,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
const int INF = 1e9;
vector<int> G[MAXN];

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if (k < n) {
    cout << k - 1 << '\n';
  } else if (k > n) {
    puts("-1");
  } else {
    cout << n - 1 << '\n';
  }
  return 0;
}
0