QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775613#9790. Make Swamp Great Againucup-team3215#WA 1ms3704kbC++23529b2024-11-23 16:19:202024-11-23 16:19:25

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 16:19:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-11-23 16:19:20]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1e5 + 1;

int cnt[N], spawn[N], a[N + 1];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n; cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], ++cnt[a[i]];
  a[n] = a[0], a[n + 1] = a[1];
  for (int i = 0; i < n; ++i) {
    spawn[min({a[i], a[i + 1], a[i + 2]})] = 1;
    spawn[max({a[i], a[i + 1], a[i + 2]})] = 1;
  }
  int ans = N;
  for (int i = 1; i < N; ++i) ans = min(ans, n - cnt[i] + 1 - spawn[i]);
  cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3704kb

input:

6
4 7 47 4 77 47

output:

4

result:

wrong answer 1st lines differ - expected: '4 6 4 4 5 4', found: '4'