結果
問題 |
No.1965 Heavier
|
ユーザー |
![]() |
提出日時 | 2022-06-06 15:46:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 821 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 41,540 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 04:39:41 |
合計ジャッジ時間 | 2,821 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
/* -*- coding: utf-8 -*- * * 1965.cc: No.1965 Heavier - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], bs[MAX_N]; /* subroutines */ inline bool win(int i, int j) { int w0, w1; if (bs[i] < bs[j]) w0 = as[i] + bs[j], w1 = as[j] + bs[i]; else w0 = as[i] + bs[i], w1 = as[j] + bs[j]; return (w0 < w1); } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); for (int i = 0; i < n; i++) scanf("%d", bs + i); ll sum = 0; for (int i = 0; i < n;) { int j = i; i++; while (i < n && win(i - 1, i)) i++; int l = i - j; sum += (ll)l * (l - 1) / 2; } printf("%lld\n", sum); return 0; }