結果

問題 No.1965 Heavier
ユーザー keisuke6keisuke6
提出日時 2022-06-03 23:08:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 246,440 KB
実行使用メモリ 6,504 KB
最終ジャッジ日時 2023-10-21 02:20:18
合計ジャッジ時間 7,858 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 149 ms
6,504 KB
testcase_07 AC 150 ms
6,504 KB
testcase_08 AC 140 ms
6,504 KB
testcase_09 AC 154 ms
6,504 KB
testcase_10 AC 154 ms
6,504 KB
testcase_11 AC 154 ms
6,504 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 149 ms
6,504 KB
testcase_16 AC 151 ms
6,504 KB
testcase_17 AC 101 ms
5,448 KB
testcase_18 AC 147 ms
6,504 KB
testcase_19 AC 142 ms
6,240 KB
testcase_20 AC 146 ms
6,504 KB
testcase_21 AC 133 ms
6,240 KB
testcase_22 AC 130 ms
5,976 KB
testcase_23 AC 91 ms
5,184 KB
testcase_24 AC 115 ms
5,712 KB
testcase_25 AC 141 ms
6,504 KB
testcase_26 AC 136 ms
6,504 KB
testcase_27 AC 159 ms
6,504 KB
testcase_28 AC 159 ms
6,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++) cin>>B[i];
  int streak = 0;
  int ans = 0;
  for(int i=1;i<N;i++){
      if(A[i]+min(B[i],B[i-1]) > A[i-1]+max(B[i],B[i-1])) streak++;
      else{
          ans += streak*(streak+1)/2;
          streak=0;
      }
  }
  ans += streak*(streak+1)/2;
  cout<<ans<<endl;
}
0