結果
問題 |
No.994 ばらばらコイン
|
ユーザー |
|
提出日時 | 2020-03-27 03:32:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 448 bytes |
コンパイル時間 | 1,775 ms |
コンパイル使用メモリ | 168,964 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-02 07:53:34 |
合計ジャッジ時間 | 3,639 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 WA * 16 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i<(n); ++i) using namespace std; using ll=long long; int main(){ int n,k; cin>>n>>k; if(n<k){ cout<<-1<<endl; return 0; } map<int,int>mp; mp.insert(make_pair(1,k)); int ans=0; rep(i,n-1){ int a,b; cin>>a>>b; if(mp[a]>1){ mp[a]--; mp[b]++; ans++; } } cout<<ans<<endl; }