結果
問題 |
No.871 かえるのうた
|
ユーザー |
![]() |
提出日時 | 2019-08-30 21:53:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,156 bytes |
コンパイル時間 | 1,594 ms |
コンパイル使用メモリ | 168,268 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 22:47:03 |
合計ジャッジ時間 | 3,823 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 31 |
ソースコード
// 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] - a[t]) { break; } t--; } t = k - 1; while (t <= n - 1) { if (right < x[t] + a[t]) { break; } t++; } ll cnt = 0; REP(i, n) { if (x[i] >= left && x[i] <= right) cnt++; } cout << cnt << endl; return 0; }