結果

問題 No.711 競技レーティング単調増加
ユーザー chocoruskchocorusk
提出日時 2018-10-09 23:02:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,810 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 94,328 KB
実行使用メモリ 7,624 KB
最終ジャッジ日時 2024-04-20 19:20:26
合計ジャッジ時間 19,991 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,248 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 642 ms
7,424 KB
testcase_31 AC 721 ms
7,296 KB
testcase_32 AC 754 ms
7,424 KB
testcase_33 AC 856 ms
7,296 KB
testcase_34 AC 748 ms
7,500 KB
testcase_35 AC 875 ms
7,500 KB
testcase_36 AC 717 ms
7,624 KB
testcase_37 AC 756 ms
7,424 KB
testcase_38 AC 679 ms
7,424 KB
testcase_39 AC 334 ms
5,376 KB
testcase_40 AC 470 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 384 ms
5,376 KB
testcase_43 AC 584 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

const int MAX_N=1<<18;
const int INF=1100000000;
    
int mn[2*MAX_N-1], part[2*MAX_N-1];
int m;
   
void init(int n){
    m=1;
    while(m<n) m*=2;
    for(int i=0; i<2*m-1; i++){
        mn[i]=INF;
        part[i]=INF;
    }
}
  
void eval(int k, int l, int r){
    if(part[k]<INF){
        mn[k]=min(mn[k], part[k]);
        if(k<m-1){
            part[2*k+1]=min(part[k], part[2*k+1]);
            part[2*k+2]=min(part[k], part[2*k+2]);
        }
        part[k]=INF;
    }
}
    
void update(int a, int b, int x, int k, int l, int r){
	eval(k, l, r);
	if(r<=a || b<=l) return;
    if(a<=l && r<=b){
        part[k]=min(x, part[k]);
        eval(k, l, r);
    }else{
        update(a, b, x, k*2+1, l, (l+r)/2);
        update(a, b, x, k*2+2, (l+r)/2, r);
        mn[k]=min(mn[2*k+1], mn[2*k+2]);
    }
}
    
int find(int a, int b, int k, int l, int r){
	eval(k, l, r);
    if(b<=l || r<=a){
        return INF;
    }
    if(a<=l && r<=b){
        return mn[k];
    }else{
        return min(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
    }
}

int main()
{
	int n;
	cin>>n;
	init(n+1);
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		int i1=1, i2=n+1;
		while(i1!=i2){
			int i0=(i1+i2)/2;
			if(find(0, i0+1, 0, 0, m)>=a-i) i1=i0+1;
			else i2=i0;
		}
		update(i1-1, n+1, a-i-1, 0, 0, m);
	}
	int i1=1, i2=n+1;
	while(i1!=i2){
		int i0=(i1+i2)/2;
		if(find(0, i0+1, 0, 0, m)>=INF) i1=i0+1;
		else i2=i0;
	}
	cout<<i1-1<<endl;
	return 0;
}
0