結果
問題 |
No.3049 Contest Coordinator
|
ユーザー |
|
提出日時 | 2025-03-07 22:28:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 175 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 2,329 ms |
コンパイル使用メモリ | 198,816 KB |
実行使用メモリ | 8,604 KB |
最終ジャッジ日時 | 2025-03-07 22:28:39 |
合計ジャッジ時間 | 10,534 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 58 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d%d%d",&n,&t,&x,&y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:14:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | for(i=1;i<=n;i++) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF=0x3f3f3f3f; const ll LLINF=0x3f3f3f3f3f3f3f3fLL; const int MAX=5e5+10; const int mod=998244353; int a[MAX]; int main() { int n,t,x,y,i,j,l,now; ll ans; scanf("%d%d%d%d",&n,&t,&x,&y); for(i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+1+n); vector<int> res; l=1; for(i=2;i<=n;i++) { if(a[i]-a[i-1]>t) { res.push_back(i-l); l=i; } } res.push_back(n-l+1); sort(res.begin(),res.end()); reverse(res.begin(),res.end()); j=0; now=res[0]; ans=0; for(i=1;i<=n;i++) { if(i>now) { ans+=min(x,y); j++; now+=res[j]; } printf("%lld%c",ans," \n"[i==n]); } return 0; } /* 顺序自选 所以可以sort之后,选区间一定是最优的 1 2 3 4 5 11 12 13 14 15 11 12 13 14 15 1 2 3 4 5 min(x,y) */