結果

問題 No.871 かえるのうた
ユーザー kuhakukuhaku
提出日時 2019-11-03 23:07:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,216 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 166,648 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-10-13 01:51:21
合計ジャッジ時間 6,505 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,352 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 121 ms
4,556 KB
testcase_17 AC 98 ms
4,728 KB
testcase_18 AC 17 ms
4,352 KB
testcase_19 WA -
testcase_20 AC 9 ms
4,348 KB
testcase_21 AC 43 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 34 ms
4,352 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 20 ms
4,352 KB
testcase_35 WA -
testcase_36 AC 71 ms
4,412 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 29 ms
4,348 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 29 ms
4,348 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FOR(i, 1, n+1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	int n, k;
	cin >> n >> k;

	vector<ll> x(n);
	vector<ll> a(n);
	rep(i, n) cin >> x[i];
	rep(i, n) cin >> a[i];

	int ans = 1, left = k-2, right = k;
	ll left_x = x[k-1]-a[k-1], right_x = x[k-1]+a[k-1];
	while(x[left] >= left_x && x[right] <= right_x && ans < n){
		if(left >= 0 && x[left] >= left_x){
			left_x = min(left_x, x[left]-a[left]);
			right_x = max(right_x, x[left]+a[left]);
			ans++;
			left--;
		}
		if(right < n && x[right] <= right_x){
			left_x = min(left_x, x[right]-a[right]);
			right_x = max(right_x, x[right]+a[right]);
			ans++;
			right++;
		}
	}

	co(ans);

	return 0;
}
0