結果
問題 | No.1965 Heavier |
ユーザー |
![]() |
提出日時 | 2022-06-04 20:41:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 573 bytes |
コンパイル時間 | 1,966 ms |
コンパイル使用メモリ | 195,816 KB |
最終ジャッジ日時 | 2025-01-29 18:12:22 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;cin>>n;vector<ll> A(n),B(n),C(n),D(n);rep(i,n) cin>>A[i];rep(i,n) cin>>B[i];rep(i,n) C[i]=A[i]-B[i];rep(i,n) D[i]=A[i]+B[i];ll ans=0,r=0;rep(l,n-1){while(r<n-1 && ((B[r]<B[r+1] && C[r+1]>C[r]) ||(B[r]>=B[r+1] && D[r+1]>D[r]))) r++;ans+=r-l;if(r==l) r++;}cout<<ans<<endl;return 0;}