Submission #1114847

# Submission time Handle Problem Language Result Execution time Memory
1114847 2024-11-19T17:06:24 Z ortsac Dancing Elephants (IOI11_elephants) C++17
10 / 100
2 ms 6480 KB
#pragma GCC optimize("O3")
#include "elephants.h"
#include <bits/stdc++.h>

using namespace std;

int n, l;
vector<int> v;
vector<int> po;
const int INF = (1e9 + 1);

void init(int N, int L, int X[])
{
  n = N;
  l = L;
  v.resize(n);
  po.resize(n);
  for (int i = 0; i < n; i++) {
    po[i] = i;
    v[i] = X[i];
  }
}

int update(int i, int y) {
  if (v[po[i]] < y) {
    v[po[i]] = y;
    int lst = -INF, qtd = 0;
    for (int i = 0; i < n; i++) {
      if ((i < (n - 1)) && (v[i] > v[i + 1])) {
        swap(v[i], v[i + 1]);
        swap(po[i], po[i + 1]);
      }
      if (v[i] > (lst + l)) {
        lst = v[i];
        qtd++;
      }
    }
    return qtd;
  } else {
    v[po[i]] = y;
    int lst = INF, qtd = 0;
    for (int i = n - 1; i >= 0; i--) {
      if ((i > 0) && (v[i] < v[i - 1])) {
        swap(v[i], v[i - 1]);
        swap(po[i], po[i - 1]);
      }
      if (v[i] < (lst - l)) {
        lst = v[i];
        qtd++;
      }
    }
    return qtd;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Incorrect 1 ms 6480 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Incorrect 1 ms 6480 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Incorrect 1 ms 6480 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Incorrect 1 ms 6480 KB Output isn't correct
5 Halted 0 ms 0 KB -