結果
| 問題 | No.3760 Streaming Schedule |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-16 14:10:34 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 31 ms / 2,000 ms |
| + 631µs | |
| コード長 | 2,107 bytes |
| 記録 | |
| コンパイル時間 | 7,122 ms |
| コンパイル使用メモリ | 394,584 KB |
| 実行使用メモリ | 20,092 KB |
| 最終ジャッジ日時 | 2026-10-16 14:10:54 |
| 合計ジャッジ時間 | 12,149 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;
// using mint=modint998244353;
// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;
#line 2 "data-structure/slide-window-aggregation.hpp"
#include <vector>
using namespace std;
template <typename T, typename F>
struct SlideWindowAggregation {
vector<T> a0, a1, r0, r1;
F f;
T I, f0, f1;
SlideWindowAggregation(F _f, T _i) : f(_f), I(_i), f0(_i), f1(_i) {}
private:
void push_s0(const T &x) {
a0.push_back(x);
r0.push_back(f0 = f(x, f0));
}
void push_s1(const T &x) {
a1.push_back(x);
r1.push_back(f1 = f(f1, x));
}
void transfer() {
while (!a1.empty()) {
push_s0(a1.back());
a1.pop_back();
}
while (!r1.empty()) r1.pop_back();
f1 = I;
}
public:
void push(const T &x) {
if (a0.empty()) {
push_s0(x);
transfer();
} else {
push_s1(x);
}
}
void pop() {
if (a0.empty()) transfer();
a0.pop_back();
r0.pop_back();
f0 = r0.empty() ? I : r0.back();
}
T query() { return f(f0, f1); }
};
/**
* @brief Slide Window Aggrigation
* @docs docs/data-structure/slide-window-aggregation.md
*/
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N,B,C;
cin>>N>>B>>C;
ll neg=-LONG_LONG_MAX;
auto op=[](ll a,ll b){return max(a,b);};
SlideWindowAggregation<ll,decltype(op)>wg(op,neg),wf(op,neg);
wg.push(0);
wf.push(0);
ll f=0,g=0,P=0;
rep(i,0,N){
ll a;
cin>>a;
P+=a;
if(i>=B-1)wg.pop();
if(i>=C-1)wf.pop();
f=wg.query();
g=P+wf.query();
wg.push(g);
wf.push(f-P);
}
cout<<max(f,g)<<'\n';
}
C