結果

問題 No.1188 レベルX門松列
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2020-08-22 15:52:41
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,434 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 143,464 KB
実行使用メモリ 155,776 KB
最終ジャッジ日時 2024-04-23 10:08:45
合計ジャッジ時間 9,909 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 213 ms
11,648 KB
testcase_08 AC 195 ms
11,648 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0