結果
| 問題 | No.3512 moesode |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-24 21:35:19 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 673 bytes |
| 記録 | |
| コンパイル時間 | 1,736 ms |
| コンパイル使用メモリ | 222,584 KB |
| 実行使用メモリ | 7,008 KB |
| 最終ジャッジ日時 | 2026-04-24 21:35:26 |
| 合計ジャッジ時間 | 3,394 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,M,K; cin >> N >> M >> K;
vector<int> A(N),B(N);
while(M--){
int a,b; cin >> a >> b,a--,b--;
A.at(a)++,B.at(b)++;
}
long long answer = 0;
vector<int> out;
vector<pair<int,int>> zero;
for(int i=0; i<N; i++) if(A.at(i)) out.push_back(i);
for(int i=0; i<N; i++) if(A.at(i) == 0) zero.push_back({B.at(i),i});
sort(zero.rbegin(),zero.rend());
for(auto [ign,pos] : zero) if(out.size() <= K) out.push_back(pos);
for(auto pos : out) answer += max(0,K-B.at(pos));
cout << answer << endl;
}