Submission #1093778

# Submission time Handle Problem Language Result Execution time Memory
1093778 2024-09-27T12:13:16 Z ramzialoulou Nizin (COCI16_nizin) C++17
0 / 100
34 ms 6244 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef Ramzi
#include "debug.h"
#else
#define debug(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 0 << "\n";
    return 0;
  }
  if (n == 2) {
    cout << (a[0] == a[1] ? 0 : 1) << "\n";
    return 0;
  }
  int l = 0, r = n - 1;
  int ans = 0;
  while (l < r) {
    if (a[l] != a[r]) {
      ++ans;
      if (a[l] + a[l + 1] == a[r]) {
        ++l;
      } else if (a[r] + a[r - 1] == a[l]){
        --r;
      } else {
        ++ans;
        ++l, --r;
      }
    }
    ++l, --r;
  }
  cout << ans << "\n";
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 6244 KB Output isn't correct
2 Halted 0 ms 0 KB -