結果
問題 |
No.3198 Monotonic Query
|
ユーザー |
|
提出日時 | 2025-07-12 10:35:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 73 ms / 3,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 2,145 ms |
コンパイル使用メモリ | 202,544 KB |
実行使用メモリ | 8,704 KB |
最終ジャッジ日時 | 2025-07-12 10:56:46 |
合計ジャッジ時間 | 4,741 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d%d", &op, &a); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f; ll res; int n, m, cnt, w[N]; int main() { cin >> m; set<pii> st; while (m--) { int op, a; scanf("%d%d", &op, &a); if (op == 1) { w[++n] = a; while (st.size() && st.rbegin()->second <= w[n]) st.erase(*st.rbegin()); st.insert({n, a}); } else printf("%d\n", st.lower_bound({n - a + 1, -INF})->second); } return 0; }