Submission #901854

#TimeUsernameProblemLanguageResultExecution timeMemory
901854nguyentunglamDancing Elephants (IOI11_elephants)C++17
26 / 100
9042 ms9580 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;

const int N = 1e5 + 10;

int n, l;

int a[N], b[N];

void init(int N, int L, int X[])
{
  n = N;

  l = L;

  for(int i = 0; i < n; i++) a[i] = X[i];
}

int update(int i, int y)
{
  a[i] = y;
  for(int i = 0; i < n; i++) b[i] = a[i];

  sort(b, b + n);

  int pre = -1e9, ans = 0;

  for(int i = 0; i < n; i++) if (b[i] - pre > l) {
    pre = b[i];
    ans++;
  }

  return ans;
}

#ifdef ngu
int x[N];
int main() {

  freopen ("task.inp", "r", stdin);
  freopen ("task.out", "w", stdout);

  int n, l, m; cin >> n >> l >> m;

  for(int i = 0; i < n; i++) cin >> x[i];

  init(n, l, x);

  while (m--) {
    int i, v; cin >> i >> v;
    cout << update(i, v) << endl;
  }
}
#endif // ngu

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...