結果
| 問題 | No.1734 Decreasing Elements |
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-11-05 22:50:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,439 bytes |
| コンパイル時間 | 1,569 ms |
| コンパイル使用メモリ | 132,936 KB |
| 最終ジャッジ日時 | 2025-01-25 13:34:31 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 5 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <random>
#include <atcoder/lazysegtree>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
vector<int> gen_array(int n, int l, int r){
int d = r-l;
random_device rnd;
mt19937 mt(rnd());
vector<int> ans(n);
int x = mt();
for(int i = 0; i < n; i++) ans[i] = l+(mt()%d);
return ans;
}
const int MX = 200000;
using P = pair<int, int>;
int e() { return 0; }
int add(int l, int r) { return l+r; }
int id() { return 0; }
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n; cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
vector<int> v(MX+1);
for(int i = 0; i <= MX; i++) v[i] = i;
atcoder::lazy_segtree<int, add, e, int, add, add, id> sgt(v);
priority_queue<P> que;
que.push(P(MX, 0));
int ans = 0;
for(int i = 0; i < n; i++){
int x = sgt.get(a[i]);
if(x == 0) continue;
ans++;
vector<P> p;
while(!que.empty() && que.top().first >= x+1){
p.push_back(que.top());
que.pop();
}
// debug_value(p.size());
for(auto [len, l]: p){
que.push(P(x, l));
que.push(P(len-x, l+x));
sgt.apply(l+x, l+len, -x);
}
}
cout << ans << endl;
}
milanis48663220