結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 153 ms
5,728 KB
testcase_07 AC 153 ms
5,728 KB
testcase_08 WA -
testcase_09 AC 158 ms
5,728 KB
testcase_10 AC 158 ms
5,728 KB
testcase_11 AC 157 ms
5,728 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 152 ms
5,728 KB
testcase_16 AC 152 ms
5,728 KB
testcase_17 AC 102 ms
4,936 KB
testcase_18 AC 151 ms
5,728 KB
testcase_19 AC 145 ms
5,728 KB
testcase_20 AC 150 ms
5,728 KB
testcase_21 AC 136 ms
5,464 KB
testcase_22 AC 133 ms
5,464 KB
testcase_23 AC 93 ms
4,672 KB
testcase_24 AC 117 ms
5,200 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 162 ms
5,728 KB
testcase_28 AC 162 ms
5,728 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;
	vector<ll>memo(n,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]))
		{
			memo[i]=i;
		}else{
			memo[i]=memo[i-1];
			ans+=i-memo[i];
		}
	}
	cout << ans << endl;
}
0