結果
問題 | No.871 かえるのうた |
ユーザー |
👑 |
提出日時 | 2022-08-18 21:56:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 144 ms / 2,000 ms |
コード長 | 554 bytes |
コンパイル時間 | 905 ms |
コンパイル使用メモリ | 80,924 KB |
最終ジャッジ日時 | 2025-01-30 23:59:21 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include <iostream>#include <queue>using namespace std;int main(){long long n,k;cin>>n>>k;vector<long long> X(n),A(n);for(int i = 0; n > i; i++)cin>>X[i];for(int i = 0; n > i; i++)cin>>A[i];vector<bool> G(n);queue<int> b;b.push(k-1);int nwl = k-1,nwr = k-1;while(b.size()){auto z = b.front();b.pop();while(nwr+1 != n && X[nwr+1]-X[z] <= A[z]){nwr++;b.push(nwr);}while(nwl-1 >= 0 && X[z]-X[nwl-1] <= A[z]){nwl--;b.push(nwl);}}cout << nwr-nwl+1 << endl;}