結果

問題 No.711 競技レーティング単調増加
ユーザー azbrugbyazbrugby
提出日時 2019-03-05 00:27:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 77,948 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-05 18:36:37
合計ジャッジ時間 5,131 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:91: warning: overflow in conversion from ‘long int’ to ‘ll’ {aka ‘int’} changes value from ‘-72340172838’ to ‘674271194’ [-Woverflow]
 const ll MOD = 1000000007, N = 200001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;
                                                                                           ^~~~~~~~~~~
main.cpp:19:110: warning: overflow in conversion from ‘long int’ to ‘ll’ {aka ‘int’} changes value from ‘72340172838’ to ‘-674271194’ [-Woverflow]
 const ll MOD = 1000000007, N = 200001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;
                                                                                                              ^~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#define mk make_pair
#define pb push_back
#define printf printf_s
#define scanf scanf_s
using namespace std;
typedef int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 200001, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

ll pw(ll v1, ll v2) {
	ll v3 = 1;
	while (v2 > 0) {
		if (v2 % 2)v3 = (v3*v1) % MOD;
		v1 = (v1*v1) % MOD;
		v2 /= 2;
	}
	return v3;
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};

ll hl[N],a[N],n,bt[N];

void ad(ll v1, ll v2) {
	while (v1 <= n) {
		bt[v1] =min(bt[v1],v2);
		v1 += v1 & -v1;
	}
}

ll sm(ll v1) {
	ll v2 = 0;
	while (v1 > 0) { v2 =min(v2,bt[v1]); v1 -= v1 & -v1; }
	return v2;
}

int main() {
	cin >> n; 
	for (int i = 1; i <= n; i++) { 
		cin >> a[i];
		hl[i] = a[i]-i;
	}

	sort(hl + 1, hl + n + 1);
	
	for (int i = 1; i <= n; i++) {
		ll v1 = sm(upper_bound(hl + 1, hl + n + 1, a[i]-i) - hl - 1);
		ll v2 = v1 + i - 1;
		ad(find(hl + 1, hl + n + 1, a[i]-i) - hl, v2 - i);
	}

	cout << sm(n) + n << endl;
	return 0;
}
0