Submission #1093960

# Submission time Handle Problem Language Result Execution time Memory
1093960 2024-09-28T06:58:41 Z Aviansh Dancing Elephants (IOI11_elephants) C++17
50 / 100
9000 ms 4180 KB
#include <bits/stdc++.h>
#include "elephants.h"

using namespace std;

int n;
int l;
int *x;
map<int,int>mp;
vector<int>uni;

void init(int N, int L, int X[])
{
    n = N;
    l=L;
    x=X;
    for(int i = 0;i<n;i++){
        mp[x[i]]++;
    }
    for(pair<int,int>p:mp){
        uni.push_back(p.first);
    }
    sort(uni.begin(),uni.end());
}

int update(int i, int y)
{
    mp[x[i]]--;
    if(mp[x[i]]==0){
        mp.erase(x[i]);
        uni.erase(lower_bound(uni.begin(),uni.end(),x[i]));
    }
    x[i]=y;
    mp[x[i]]++;
    if(mp[x[i]]==1){
        int ind = lower_bound(uni.begin(),uni.end(),x[i])-uni.begin();
        uni.insert(uni.begin()+ind,x[i]);
    }
    int ans = 1;
    int las = uni[0];
    for(int i : uni){
        if(i-las>l){
            las=i;
            ans++;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 541 ms 1780 KB Output is correct
8 Correct 1154 ms 2140 KB Output is correct
9 Correct 1627 ms 3932 KB Output is correct
10 Correct 1833 ms 3912 KB Output is correct
11 Correct 1855 ms 3928 KB Output is correct
12 Correct 4935 ms 3928 KB Output is correct
13 Correct 2013 ms 3836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 541 ms 1780 KB Output is correct
8 Correct 1154 ms 2140 KB Output is correct
9 Correct 1627 ms 3932 KB Output is correct
10 Correct 1833 ms 3912 KB Output is correct
11 Correct 1855 ms 3928 KB Output is correct
12 Correct 4935 ms 3928 KB Output is correct
13 Correct 2013 ms 3836 KB Output is correct
14 Correct 425 ms 2140 KB Output is correct
15 Correct 3415 ms 2652 KB Output is correct
16 Execution timed out 9053 ms 4180 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 541 ms 1780 KB Output is correct
8 Correct 1154 ms 2140 KB Output is correct
9 Correct 1627 ms 3932 KB Output is correct
10 Correct 1833 ms 3912 KB Output is correct
11 Correct 1855 ms 3928 KB Output is correct
12 Correct 4935 ms 3928 KB Output is correct
13 Correct 2013 ms 3836 KB Output is correct
14 Correct 425 ms 2140 KB Output is correct
15 Correct 3415 ms 2652 KB Output is correct
16 Execution timed out 9053 ms 4180 KB Time limit exceeded
17 Halted 0 ms 0 KB -