結果
| 問題 | No.3512 moesode |
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2026-04-24 21:25:20 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 2,000 ms |
| コード長 | 706 bytes |
| 記録 | |
| コンパイル時間 | 3,477 ms |
| コンパイル使用メモリ | 276,292 KB |
| 実行使用メモリ | 8,268 KB |
| 最終ジャッジ日時 | 2026-04-24 21:25:28 |
| 合計ジャッジ時間 | 6,025 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001LL
int main(){
long long N,M,K;
cin>>N>>M>>K;
vector<long long> x(N),y(N);
rep(i,M){
int a,b;
cin>>a>>b;
a--,b--;
x[a] ++;
y[b] ++;
}
long long ans = 0;
long long num = 0;
vector<long long> cost;
rep(i,N){
if(x[i]>0){
num++;
ans += max(0LL,K - y[i]);
}
else{
cost.push_back(max(0LL,K - y[i]));
}
}
sort(cost.begin(),cost.end());
if(num < K+1){
rep(i,K+1 - num)ans += cost[i];
}
cout<<ans<<endl;
return 0;
}
沙耶花