結果
問題 |
No.1965 Heavier
|
ユーザー |
|
提出日時 | 2022-06-25 01:02:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 499 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 66,048 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 19:47:14 |
合計ジャッジ時間 | 5,261 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int a[200009], b[200009]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; int c = 0; long long ans = 0; for (int i = 1; i <= n; i++) { c++; if (i == n || a[i] + b[i] >= a[i + 1] + b[i + 1] || a[i] - b[i] >= a[i + 1] - b[i + 1]) { ans += 1LL * c * (c - 1) / 2LL; c = 0; } } cout << ans << '\n'; return 0; }