結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
uk714
|
| 提出日時 | 2019-08-30 21:57:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,222 bytes |
| コンパイル時間 | 1,556 ms |
| コンパイル使用メモリ | 168,584 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 23:14:20 |
| 合計ジャッジ時間 | 3,665 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 WA * 8 |
ソースコード
// https://yukicoder.me/problems/no/871
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, k;
cin >> n >> k;
vector<ll> x(n), a(n);
REP(i, n) cin >> x[i];
REP(i, n) cin >> a[i];
ll t = k - 1;
ll left = x[t] - a[t], right = x[t] + a[t];
while (t >= 0) {
if (left > x[t]) {
break;
}
left = min(left, x[t] - a[t]);
t--;
}
t = k - 1;
while (t <= n - 1) {
if (right < x[t]) {
break;
}
right = max(right, x[t] + a[t]);
t++;
}
ll cnt = 0;
REP(i, n) {
if (x[i] >= left && x[i] <= right)
cnt++;
}
cout << cnt << endl;
return 0;
}
uk714