結果

問題 No.1965 Heavier
ユーザー hiro71687khiro71687k
提出日時 2023-03-07 09:37:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 4,411 ms
コンパイル使用メモリ 262,736 KB
実行使用メモリ 8,124 KB
最終ジャッジ日時 2023-10-18 05:27:02
合計ジャッジ時間 8,911 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 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 151 ms
8,124 KB
testcase_07 AC 152 ms
8,124 KB
testcase_08 AC 142 ms
8,124 KB
testcase_09 AC 157 ms
8,124 KB
testcase_10 AC 158 ms
8,124 KB
testcase_11 AC 158 ms
8,124 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
8,124 KB
testcase_16 AC 151 ms
8,124 KB
testcase_17 AC 103 ms
6,540 KB
testcase_18 AC 152 ms
8,124 KB
testcase_19 AC 144 ms
7,860 KB
testcase_20 AC 149 ms
8,124 KB
testcase_21 AC 134 ms
7,596 KB
testcase_22 AC 133 ms
7,596 KB
testcase_23 AC 93 ms
6,276 KB
testcase_24 AC 118 ms
7,068 KB
testcase_25 AC 145 ms
8,124 KB
testcase_26 AC 138 ms
8,124 KB
testcase_27 AC 161 ms
8,124 KB
testcase_28 AC 161 ms
8,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
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