結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-01 05:18:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 115 ms / 2,000 ms |
| コード長 | 911 bytes |
| コンパイル時間 | 453 ms |
| コンパイル使用メモリ | 68,000 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-30 10:55:03 |
| 合計ジャッジ時間 | 3,322 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int N,K;
long X[1<<17],A[1<<17];
main()
{
cin>>N>>K;
for(int i=0;i<N;i++)cin>>X[i];
for(int i=0;i<N;i++)cin>>A[i];
long L=X[--K]-A[K],R=X[K]+A[K];
int cnt=1;
int l=K-1,r=K+1;
while(l>=0||r<N)
{
long ll=l>=0?X[K]-X[l]:(long)9e18;
long rr=r<N?X[r]-X[K]:(long)9e18;
if(ll<rr)
{
if(L<=X[l])
{
cnt++;
L=min(L,X[l]-A[l]);
R=max(R,X[l]+A[l]);
l--;
}
else
{
if(rr<(long)9e18&&X[r]<=R)
{
cnt++;
L=min(L,X[r]-A[r]);
R=max(R,X[r]+A[r]);
r++;
}
else
{
break;
}
}
}
else
{
if(R>=X[r])
{
cnt++;
L=min(L,X[r]-A[r]);
R=max(R,X[r]+A[r]);
r++;
}
else
{
if(ll<(long)9e18&&L<=X[l])
{
cnt++;
L=min(L,X[l]-A[l]);
R=max(R,X[l]+A[l]);
l--;
}
else
{
break;
}
}
}
}
cout<<cnt<<endl;
}