結果
| 問題 |
No.1188 レベルX門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 15:52:41 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,434 bytes |
| コンパイル時間 | 5,202 ms |
| コンパイル使用メモリ | 141,792 KB |
| 実行使用メモリ | 155,904 KB |
| 最終ジャッジ日時 | 2024-10-15 10:02:07 |
| 合計ジャッジ時間 | 12,268 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 16 |
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
using int64 = long long;
class BIT {
int64 n;
map<int64,int64> d;
public:
BIT(int64 _n=0) {n=_n; };
void add(int64 i, int64 x=1) { for (i++; i <= n; i += i&-i) d[i] += x; }
int64 sum(int64 i) { int64 x = 0; for (i++; i; i -= i&-i) x += d[i]; return x; }
};
int main() {
int64 n;
cin >> n;
vector a(n,0LL);
int64 a_max = 0;
for (int64 i=0; i<n; i++) {
cin >> a[i];
a_max = max(a_max, a[i]);
}
BIT bit1(a_max+1);
vector l(n,0LL);
for (int64 i=0; i<n; i++) {
l[i] = bit1.sum(a[i]);
bit1.add(a[i]);
}
BIT bit2(a_max+1);
vector r(n,0LL);
for (int64 i=n-1; i>=0; i--) {
r[i] = bit2.sum(a[i]);
bit2.add(a[i]);
}
int64 ans = 0;
for (int i=1; i<n-1; i++) {
ans = max(ans, min(l[i], r[i]));
ans = max(ans, min(i-l[i], n-i-1-r[i]));
}
cout << ans << endl;
}