結果

問題 No.1965 Heavier
ユーザー Nzt3Nzt3
提出日時 2022-06-03 22:23:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 170,468 KB
実行使用メモリ 7,164 KB
最終ジャッジ日時 2023-10-21 02:01:28
合計ジャッジ時間 4,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 49 ms
7,164 KB
testcase_07 AC 49 ms
7,164 KB
testcase_08 AC 46 ms
7,164 KB
testcase_09 AC 50 ms
7,164 KB
testcase_10 AC 51 ms
7,164 KB
testcase_11 AC 50 ms
7,164 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 49 ms
7,164 KB
testcase_16 AC 49 ms
7,164 KB
testcase_17 AC 34 ms
5,992 KB
testcase_18 AC 49 ms
7,164 KB
testcase_19 AC 47 ms
6,900 KB
testcase_20 AC 48 ms
7,164 KB
testcase_21 AC 44 ms
6,680 KB
testcase_22 AC 44 ms
6,636 KB
testcase_23 AC 30 ms
5,580 KB
testcase_24 AC 39 ms
6,372 KB
testcase_25 AC 47 ms
7,164 KB
testcase_26 AC 45 ms
7,164 KB
testcase_27 AC 52 ms
7,164 KB
testcase_28 AC 51 ms
7,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N),B(N);
  for(int &i:A)cin>>i;
  for(int &i:B)cin>>i;
  vector<int>sa(N),wa(N);
  for(int i=0;i<N;i++){
    sa[i]=A[i]-B[i];
    wa[i]=A[i]+B[i];
  }
  wa.push_back(-2e9),sa.push_back(-2e9);
  long long ans=0;
  for(long long i=1,cnt=1;i<=N;i++){
    if(sa[i-1]>=sa[i]||wa[i-1]>=wa[i]){
      ans+=cnt*(cnt-1)/2;
      cnt=1;
    }else{
      cnt+=1;
    }
  }
  cout<<ans<<'\n';
}
0