結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-03-10 20:37:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 1,559 ms |
| コンパイル使用メモリ | 170,492 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 11:00:15 |
| 合計ジャッジ時間 | 3,663 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
ソースコード
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
void cmn(lint&x,lint y){if(x>y)x=y;}
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
int n,k;std::cin>>n>>k;k--;
std::vector<lint>a(n),b(n);
for(auto&x:a)std::cin>>x;
for(auto&x:b)std::cin>>x;
lint L=a.at(k)-b.at(k);
lint R=a.at(k)+b.at(k);
int l=k,r=k;
while(true){
if(0<l&&L<=a.at(l-1)){
l--;
cmn(L,a.at(l)-b.at(l));
cmx(R,a.at(l)+b.at(l));
continue;
}
if(r<n-1&&a.at(r+1)<=R){
r++;
cmn(L,a.at(r)-b.at(r));
cmx(R,a.at(r)+b.at(r));
continue;
}
break;
}
std::cout<<r-l+1<<'\n';
}
ngtkana