結果

問題 No.3512 moesode
コンテスト
ユーザー t98slider
提出日時 2026-04-24 21:35:15
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 671 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,381 ms
コンパイル使用メモリ 340,332 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-24 21:35:22
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> in(n), ext(n);
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--, v--;
		ext[u]++;
		in[v]++;
	}
	vector<int> ord(n), pos(n);
	iota(ord.begin(), ord.end(), 0);
	sort(ord.begin(), ord.end(), [&](int lhs, int rhs){
		return make_pair(ext[lhs], in[lhs]) > make_pair(ext[rhs], in[rhs]);
	});
	for(int i = 0; i < n; i++) pos[ord[i]] = i;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(ext[i] >= 1 || pos[i] < k + (ext[0] >= 1)){
			ans += max(0, k - in[i]);
		}
	}
	cout << ans << '\n';
}
0