結果

問題 No.994 ばらばらコイン
ユーザー kekenxkekenx
提出日時 2020-04-02 21:38:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 448 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 168,212 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-06-28 15:19:13
合計ジャッジ時間 3,161 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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