結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
misora192
|
| 提出日時 | 2020-05-13 08:45:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 909 bytes |
| コンパイル時間 | 1,651 ms |
| コンパイル使用メモリ | 168,576 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 15:26:30 |
| 合計ジャッジ時間 | 3,832 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 29 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
k--;
vector<ll> x(n), a(n);
rep(i, n) cin >> x[i];
rep(i, n) cin >> a[i];
int ans = 1;
ll mx = x[k] + a[k];
ll mn = x[k] - a[k];
int l = k - 1;
bool lflg = true;
int r = k + 1;
bool rflg = true;
while((lflg && l >= 0) || (rflg && r < n)){
if(lflg && l >= 0){
if(x[l] < mn){
lflg = false;
}else{
ans++;
chmin(mn, x[l] + a[l]);
l--;
}
}
if(rflg && r < n){
if(x[r] > mx){
rflg = false;
}else{
ans++;
chmax(mx, x[r] + a[r]);
r++;
}
}
}
cout << ans << endl;
}
misora192