답안 #797100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797100 2023-07-29T06:41:51 Z andecaandeci Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll MAXN = 2e5 + 5;
const ll MAX = 1e18;

ll n, m, ans = MAX, arr[MAXN];

void recur(ll idx, bool ubah, ll count, pll bef) {
  pll now = {max(0ll, bef.first-m), bef.second+m};
  if (arr[idx] < now.first || arr[idx] > now.second) {
    if (!ubah) {
      return ;
    }
  }

  if (ubah) {
    count++;
  }

  if (idx == n) {
    ans = min(count, ans);
    return ;
  }

  recur(idx+1, true, count, now);
  recur(idx+1, false, count, now);
  return ;
}

int main(){
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }

  recur(1, true, 0, {0, 0});
  recur(1, false, 0, {0, 0});
  cout << ans << "\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -