結果

問題 No.1965 Heavier
ユーザー hiro71687khiro71687k
提出日時 2023-03-07 09:29:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 4,354 ms
コンパイル使用メモリ 262,572 KB
実行使用メモリ 5,068 KB
最終ジャッジ日時 2023-10-18 05:26:42
合計ジャッジ時間 10,853 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 152 ms
4,956 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 162 ms
4,956 KB
testcase_28 AC 161 ms
4,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.14159265359;
ll inf=1001;
ll mod=998244353;
int main(){
	ll n;
	cin >> n;
	vector<ll>a(n),b(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (ll i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	ll ans=0;
	for (ll i = 1; i < n; i++)
	{
		if (a[i]+min(b[i],b[i-1])<=a[i-1]+max(b[i],b[i-1]))
		{
			continue;
		}
		ll right=i-1;
		ll left=-1;
		while (right-left>1)
		{
			ll mid=(right+left)/2;
			if (a[i]+min(b[i],b[mid])<=a[mid]+max(b[i],b[mid]))
			{
				left=mid;
			}else{
				right=mid;
			}
		}
		ans+=i-right;
	}
	cout << ans << endl;
}
0