結果

問題 No.1965 Heavier
ユーザー asaringoasaringo
提出日時 2022-06-03 22:04:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,057 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 204,076 KB
実行使用メモリ 6,756 KB
最終ジャッジ日時 2023-10-21 01:53:11
合計ジャッジ時間 4,535 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,660 KB
testcase_01 AC 2 ms
5,660 KB
testcase_02 AC 2 ms
5,660 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,660 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 46 ms
6,756 KB
testcase_28 AC 45 ms
6,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
#define fast_input_output ios::sync_with_stdio(false); cin.tie(nullptr);
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

int n ;
ll A[202020] , B[202020] ;
set<P> st_p, st_m ;

int main(){
    fast_input_output
    cin >> n ;
    rep(i,n) cin >> A[i] ;
    rep(i,n) cin >> B[i] ;
    ll p = A[0] + B[0] ;
    ll m = A[0] - B[0] ;
    ll res = 0 , count = 0 ;
    rrep(i,1,n){
        ll np = A[i] + B[i] ;
        ll nm = A[i] - B[i] ;
        if(np > p && nm > m) count++ ;
        else{
            res += count * (count + 1) / 2 ;
            count = 0 ;
        }
        p = np ;
        m = np ;
    }
    res += count * (count + 1) / 2 ;
    cout << res << endl ;
}
0