Submission #954389

# Submission time Handle Problem Language Result Execution time Memory
954389 2024-03-27T18:24:33 Z vjudge1 Dancing Elephants (IOI11_elephants) C++
26 / 100
9000 ms 9308 KB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;

int n, k;
int diff[150001];
pair<int, int> arr[150001];

bool compare(const pair<int, int> &a, const pair<int, int> &b){
  return a.second<b.second;
}

void init(int N, int L, int X[]){
  n = N;
  k=L;
  for(int i=0; i<n; i++){
    arr[i].first=X[i];
    arr[i].second=i;
  }
}

int update(int i, int y){
  sort(arr, arr+n, compare);
  arr[i].first=y;
  sort(arr, arr+n);
  for(int i=0; i<n-1; i++)
    diff[i]=arr[i+1].first-arr[i].first;
  int cnt=0, l=0, r=0, ans=0;
  while(l<n){
    r=l;
    cnt=0;
    while(r<n && diff[r]+cnt<=k){
      cnt+=diff[r];
      r++;
    }
    ans++;
    l=r+1;
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8632 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8632 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8652 KB Output is correct
6 Correct 2 ms 8644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8632 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8652 KB Output is correct
6 Correct 2 ms 8644 KB Output is correct
7 Execution timed out 9094 ms 9308 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8632 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8652 KB Output is correct
6 Correct 2 ms 8644 KB Output is correct
7 Execution timed out 9094 ms 9308 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8540 KB Output is correct
2 Correct 2 ms 8632 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 8652 KB Output is correct
6 Correct 2 ms 8644 KB Output is correct
7 Execution timed out 9094 ms 9308 KB Time limit exceeded
8 Halted 0 ms 0 KB -