結果
| 問題 |
No.1435 Mmm......
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-19 23:41:17 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,633 bytes |
| コンパイル時間 | 3,493 ms |
| コンパイル使用メモリ | 136,680 KB |
| 最終ジャッジ日時 | 2025-01-19 19:45:43 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 WA * 6 TLE * 1 |
ソースコード
#define rep(i, l, r) for (auto i = (l); i < (r); i++)
#define chmin(dest, src) if ((dest) > (src)) dest = (src)
#define chmax(dest, src) if ((dest) < (src)) dest = (src)
#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll INF = 1001001001001L;
// a'[i] = N * a[i] + i
// a[i] = a'[i] / N
using S1 = pair<ll, ll>;
S1 op1(S1 x, S1 y) {
vector<ll> xs{x.first, x.second, y.first, y.second};
sort(xs.begin(), xs.end());
unique(xs.begin(), xs.end());
return {xs[0], xs[1]};
}
S1 e1() {
return {INF, INF};
}
using S2 = ll;
S2 op2(S2 x, S2 y) {
return max(x, y);
}
S2 e2() {
return 0;
}
int main() {
ll N; cin >> N;
vector<S1> a1(N);
vector<S2> a2(N);
rep(i, 0, N) {
int x; cin >> x;
int y = x * N + i;
a1[i] = {y, y};
a2[i] = x;
}
segtree<S1, op1, e1> seg1(a1);
segtree<S2, op2, e2> seg2(a2);
ll ans = 0;
rep(l, 0, N - 1) {
ll ac = l + 2, wa = N + 1;
while (ac + 1 < wa) {
ll wj = (ac + wa) / 2;
S1 x = seg1.prod(l, wj);
ll m1 = x.first / N, m2 = x.second / N;
S2 M = seg2.prod(l, wj);
if (M <= m1 + m2) {
ac = wj;
} else {
wa = wj;
}
}
ll r = ac;
S1 y = seg1.prod(l, r);
ll m1 = y.first / N, m2 = y.second / N;
S2 M = seg2.prod(l, r);
//if (M <= m1 + m2) {
ans += r - l - 1;
//}
}
cout << ans << endl;
return 0;
}