結果

問題 No.1965 Heavier
ユーザー 沙耶花
提出日時 2022-06-03 21:32:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 4,056 ms
コンパイル使用メモリ 252,748 KB
最終ジャッジ日時 2025-01-29 17:33:28
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         rep(i,n)scanf("%d",&a[i]);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         rep(i,n)scanf("%d",&b[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000003

int op(int a,int b){
	return max(a,b);
}

int e(){
	return -Inf;
}
int main() {
	
	int n;
	cin>>n;
	
	vector<int> a(n),b(n);
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)scanf("%d",&b[i]);
	vector<int> x(n),y(n);
	rep(i,n){
		x[i] = a[i]+b[i];
		y[i] = a[i]-b[i];
	}
	
	segtree<int,op,e> s0(x),s1(y);
	
	long long ans = 0LL;
	int l = 0;
	rep(i,n){
		while(true){
			bool f = true;
			if(s0.prod(l,i)>=x[i])f = false;
			if(s1.prod(l,i)>=y[i])f = false;
			if(f)break;
			l++;
		}
		//cout<<i<<','<<l<<endl;
		ans += i-l;
	}
	cout<<ans<<endl;
	
}
0