結果
| 問題 | No.728 ギブ and テイク |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-27 03:21:41 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 643 bytes |
| 記録 | |
| コンパイル時間 | 801 ms |
| コンパイル使用メモリ | 88,140 KB |
| 実行使用メモリ | 17,112 KB |
| 最終ジャッジ日時 | 2026-01-27 03:21:50 |
| 合計ジャッジ時間 | 7,694 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 TLE * 1 -- * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long LL;
const int N = 300010;
int n;
LL a[N], l[N], r[N];
LL ans;
void Solve() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
for (int i = 1; i <= n; ++i) scanf("%lld%lld", &l[i], &r[i]);
ans = 0LL;
for (int i = 1; i <= n; ++i) {
int rmax = upper_bound(a + 1, a + n + 1, a[i] + r[i]) - a - 1;
for (int j = i + 1; j <= rmax; ++j) {
if (a[i] >= a[j] - l[j]) ++ans;
}
}
printf("%lld\n", ans);
}
int main() {
Solve();
return 0;
}