結果
問題 |
No.3050 Prefix Removal
|
ユーザー |
|
提出日時 | 2025-03-07 21:57:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 661 bytes |
コンパイル時間 | 920 ms |
コンパイル使用メモリ | 76,260 KB |
実行使用メモリ | 9,172 KB |
最終ジャッジ日時 | 2025-03-07 21:58:09 |
合計ジャッジ時間 | 12,568 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 53 WA * 2 |
ソースコード
#include <iostream> #include <queue> using namespace std; typedef long long ll; const ll INF = 1000000000000000000; int main() { int n, k; cin >> n >> k; priority_queue<ll, vector<ll>, greater<ll>> que; ll s; cin >> s; ll x = s; ll ans = -INF; for (int i = 1; i < n; i++) { ll a; cin >> a; que.push(-s); s += a; x += a * ((int)que.size() + 1); if (i >= k) { ll t = que.top(); x -= s + t; que.pop(); } if ((int)que.size() == k - 1) { ans = max(ans, x); } } cout << ans << endl; }