結果
問題 | No.1734 Decreasing Elements |
ユーザー |
![]() |
提出日時 | 2021-11-05 22:13:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 849 ms / 3,000 ms |
コード長 | 1,137 bytes |
コンパイル時間 | 3,222 ms |
コンパイル使用メモリ | 219,600 KB |
最終ジャッジ日時 | 2025-01-25 12:24:17 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#pragma GCC optimize("O3")#include<bits/stdc++.h>using namespace std;const int M = 998244353;const long long LM = 1LL << 60;int main() {cin.tie(0);ios::sync_with_stdio(0);int n;// n = 200000;cin >> n;vector<int> a(n);for (int i = 0; i < n; ++i) {// a[i] = i + 1;cin >> a[i];}vector<vector<int>> vv;int SQ = 500;vector<int> v = { 0, 200010 };int ans = 0;for (int i = 0; i < n; ++i) {for (auto& x : vv) {a[i] -= *prev(upper_bound(x.begin(), x.end(), a[i]));}a[i] -= *prev(upper_bound(v.begin(), v.end(), a[i]));if (a[i] > 0) {++ans;vector<int> nex;for (int j = 0; j < (int)v.size(); ++j) {nex.push_back(v[j]);if (j + 1 < (int)v.size() && v[j] + a[i] < v[j + 1]) {nex.push_back(v[j] + a[i]);}}v = nex;}if ((i + 1) % SQ == 0) {vv.push_back(v);v = { 0, 200010 };}}cout << ans << '\n';return 0;}