結果
| 問題 |
No.3298 K-th Slime
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-18 18:54:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,003 bytes |
| コンパイル時間 | 2,175 ms |
| コンパイル使用メモリ | 204,792 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-18 18:54:46 |
| 合計ジャッジ時間 | 6,162 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 RE * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | for (int i = 1; i < n + 1; i++) scanf("%d", w + i);
| ~~~~~^~~~~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d", &op);
| ~~~~~^~~~~~~~~~~
main.cpp:23:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
main.cpp:29:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f;
int n, m, w[N];
int k;
int main() {
cin >> n >> k >> m;
for (int i = 1; i < n + 1; i++) scanf("%d", w + i);
sort(w + 1, w + n + 1);
priority_queue<ll, vector<ll>, less<ll> > q1;
priority_queue<ll, vector<ll>, greater<ll> > q2;
for (int i = 1; i < k + 1; i++) q1.push(w[i]);
for (int i = k + 1; i < n + 1; i++) q2.push(w[i]);
while (m--) {
int op, x;
scanf("%d", &op);
if (op == 1) {
scanf("%d", &x);
if (x < q1.top()) {
q2.push(q1.top()), q1.pop();
q1.push(x);
} else q2.push(x);
} else if (op == 2) {
scanf("%d", &x);
ll u = q1.top() + x, v = q2.top(); q1.pop(), q2.pop();
q1.push(min(u, v)), q2.push(max(u, v));
} else printf("%lld\n", q1.top());
}
return 0;
}