結果

問題 No.871 かえるのうた
ユーザー m1025o1184tm1025o1184t
提出日時 2019-12-24 10:08:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,154 bytes
コンパイル時間 1,665 ms
コンパイル使用メモリ 173,688 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 14:04:45
合計ジャッジ時間 9,684 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

vector<int> res;
int n;

void flog_up(vector<ll> a,vector<ll> x,int k) {
    int i;
	for(i = k;i < n; ++i){
      if(x[i] > x[k] + a[k]){
        res[i - 1]++;
        if(i - 1 == k) break;
        flog_up(a, x, i - 1);
      }
    }
    return;
}

void flog_down(vector<ll> a,vector<ll> x,int k) {
	int i;
    for(i = k;i >= 0; --i){
      if(x[i] < x[k] - a[k]){
        res[i + 1]++;
        if(i + 1 == k) break;
        flog_down(a, x, i);
      }
    }
    return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> n >> k;
	vector<ll> x(n);
	vector<ll> a(n);
	rep(i, n) cin >> x[i];
	rep(i, n) cin >> a[i];
	k--;
	res.resize(n);
	fill(all(res), 0);
    res[k]++;
	flog_up(a, x, k);
	flog_down(a, x, k);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (res[i]) break;
		ans++;
	}
	for (int i = n - 1; i >= 0; --i) {
		if (res[i])break;
		ans++;
	}
    if(n == 1){
      dunk(1);
      return 0;
    }
  

  
  
	dunk(n - ans);

	return 0;
}
0