結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
data9824
|
| 提出日時 | 2019-09-14 02:53:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 955 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 64,716 KB |
| 実行使用メモリ | 13,884 KB |
| 最終ジャッジ日時 | 2024-07-04 18:17:37 |
| 合計ジャッジ時間 | 5,171 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 TLE * 1 -- * 32 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<long long> x(n), a(n);
vector<bool> sung(n);
for (int i = 0; i < n; ++i) {
cin >> x[i];
}
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sung[k - 1] = true;
for (;;) {
bool newlySung = false;
for (int i = 0; i < n; ++i) {
if (sung[i]) {
long long frontX = x[i] - a[i];
long long backX = x[i] + a[i];
for (int frontIndex = i;
frontIndex >= 0 && frontX <= x[frontIndex];
--frontIndex) {
if (!sung[frontIndex]) {
newlySung = true;
sung[frontIndex] = true;
}
}
for (int backIndex = i;
backIndex < n && x[backIndex] <= backX;
++backIndex) {
if (!sung[backIndex]) {
newlySung = true;
sung[backIndex] = true;
}
}
}
}
if (!newlySung) {
break;
}
}
cout << count(sung.begin(), sung.end(), true) << endl;
return 0;
}
data9824