Submission #954400

# Submission time Handle Problem Language Result Execution time Memory
954400 2024-03-27T19:12:50 Z vjudge1 Dancing Elephants (IOI11_elephants) C++17
26 / 100
14 ms 9676 KB
#include <bits/stdc++.h>

#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 62)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map 
#define pqueue priority_queue 
#define ptr(A) shared_ptr<A>

using namespace std;

struct Ele {
  ll i, p;
};
bool operator < (const Ele& a, const Ele& b) {
  if (a.p == b.p)
    return a.i < b.i;
  return a.p < b.p;
}

int n, l;
multiset<Ele> ms;
vector<ll> pos;

void init(int N, int L, int X[]) {
  n = N; l = L;
  pos.resize(n);

  range(i, 0, n) {
    pos[i] = X[i];
    ms.insert({i, pos[i]});
  }
}

int update(int i, int y) {
  ms.erase({i, pos[i]});
  pos[i] = y;
  ms.insert({i, pos[i]});

  int nxt = 0;
  int cnt = 0;
  while (nxt <= (*ms.rbegin()).p) {
    // cout << "Covered all but the ones after: ";
    // cout << nxt << ' ';
    // cout << "Maximum is " << (*ms.rbegin()).p << '\n';
    cnt++;
    auto lb = ms.lower_bound({0, nxt});
    nxt = (*lb).p+l+1;
    if (cnt > 100)
      return -1;
  }
  cout << '\n';
  return cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 14 ms 9676 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 14 ms 9676 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 14 ms 9676 KB Output isn't correct
8 Halted 0 ms 0 KB -