結果
| 問題 |
No.1435 Mmm......
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-07-28 13:06:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,155 bytes |
| コンパイル時間 | 2,676 ms |
| コンパイル使用メモリ | 200,288 KB |
| 最終ジャッジ日時 | 2025-02-15 19:49:27 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 3 WA * 21 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
using ll = long long;
const int INF = 1e9+1;
struct S{
int m1;
int m2;
};
S op1(S a, S b){
if(a.m1 < b.m1){
if(a.m2 < b.m2){
return a;
}else{
return {a.m1, b.m2};
}
}else{
if(b.m2 < a.m1){
return b;
}else{
return {b.m1, a.m1};
}
}
}
S e1(){
return {INF, INF};
}
int op2(int a, int b){
return max(a, b);
}
int e2(){
return -INF;
}
int main(){
int N, x, mx;
cin >> N;
S mi;
vector<int> a(N);
vector<S> b(N);
ll ans=0;
for (int i=0; i<N; i++){
cin >> x;
a[i] = x;
b[i] = {x, INF};
}
segtree<int, op2, e2> tmx(a);
segtree<S, op1, e1> tmi(b);
for (int i=0; i<N; i++){
int l=i, r=N, c;
while(r-l>1){
c = (l+r)/2;
mi = tmi.prod(i, c+1);
mx = tmx.prod(i, c+1);
if (mx <= mi.m1 + mi.m2) l=c;
else r=c;
}
ans += l-i;
}
cout << ans << endl;
return 0;
}
srjywrdnprkt