結果
問題 |
No.3050 Prefix Removal
|
ユーザー |
![]() |
提出日時 | 2025-03-07 23:13:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 935 bytes |
コンパイル時間 | 3,822 ms |
コンパイル使用メモリ | 281,060 KB |
実行使用メモリ | 11,348 KB |
最終ジャッジ日時 | 2025-03-07 23:13:37 |
合計ジャッジ時間 | 9,907 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 53 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); int N,K; cin>>N>>K; vector<int>A(N); rep(i,N) cin>>A.at(i); vector<ll>ruiseki(N); int cnt=0; rep(i,N){ cnt+=A.at(i); ruiseki.at(i)=cnt; } ll ans=0; int siz=0; priority_queue<int>pq; for(int i=0;i<K-1;i++){ pq.push(ruiseki.at(i)); ans+=ruiseki.at(i); siz++; } if(K==1){ ans=-100000000000; rep(i,N){ ans=max(ans,ruiseki.at(i)); } cout<<ans<<endl; return 0; } for(int i=K-1;i<N;i++){ if(pq.top()>=ruiseki.at(i)){ ans-=pq.top()-ruiseki.at(i); pq.pop(); pq.push(ruiseki.at(i)); siz=i; } } cout<<ruiseki.at(siz-1)*K-ans<<endl; }