結果
問題 |
No.871 かえるのうた
|
ユーザー |
![]() |
提出日時 | 2021-10-09 15:09:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 885 bytes |
コンパイル時間 | 1,195 ms |
コンパイル使用メモリ | 101,404 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-12 23:02:20 |
合計ジャッジ時間 | 9,771 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 7 RE * 29 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <queue> #include <map> #include <cmath> #include <iomanip> #include <set> using namespace std; int main() { int n , k; cin >> n >> k; k--; vector<long long> X(n); for (int i = 0; i < n; i++) { cin >> X[i]; } vector<long long> A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int x = k , y = k; int ans = 0; long long mx = -1e18; long long mn = 1e18; queue<int> qx , qy; qx.push(k); qy.push(k); while (qx.size() > 0 || qy.size() > 0) { x = qx.front(); qx.pop(); mx = max(mx , X[x] + A[x]); if (x + 1 < n && X[x + 1] <= mx) { qx.push(x + 1); } y = qy.front(); qy.pop(); mn = min(mn , X[y] - A[y]); if (0 <= y - 1 && mn <= X[y - 1]) { qy.push(y - 1); } } cout << x - y + 1 << endl; return 0; }