結果

問題 No.994 ばらばらコイン
ユーザー pekempeypekempey
提出日時 2020-02-21 21:26:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 167,720 KB
実行使用メモリ 8,640 KB
最終ジャッジ日時 2023-07-30 05:21:05
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 64 ms
8,524 KB
testcase_03 AC 70 ms
8,536 KB
testcase_04 AC 71 ms
8,532 KB
testcase_05 AC 34 ms
5,932 KB
testcase_06 AC 71 ms
8,640 KB
testcase_07 AC 70 ms
8,524 KB
testcase_08 AC 47 ms
6,688 KB
testcase_09 AC 64 ms
8,340 KB
testcase_10 AC 48 ms
7,128 KB
testcase_11 AC 55 ms
7,616 KB
testcase_12 AC 59 ms
7,800 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> G(N);
  rep(i, N - 1) {
    int u, v; cin >> u >> v; u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  if (K > N) {
    cout << "-1" << endl;
    return 0;
  }
  cout << K - 1 << endl;
}
0