Submission #1046562

# Submission time Handle Problem Language Result Execution time Memory
1046562 2024-08-06T16:59:20 Z oscar1f Dancing Elephants (IOI11_elephants) C++17
50 / 100
9000 ms 10588 KB
#include<bits/stdc++.h>
#include "elephants.h"
using namespace std;

const int MAX_ELEPH=150*1000+5,INFINI=1000*1000*1000+5;
int nbEleph,taillePhoto;
pair<int,int> posTri[MAX_ELEPH];

void init(int N, int L, int X[]) {
    nbEleph=N;
    taillePhoto=L;
    for (int i=0;i<nbEleph;i++) {
        posTri[i]={X[i],i};
    }
}

int calc() {
    int ans=0,dernDeb=-INFINI;
    for (int i=0;i<nbEleph;i++) {
        if (dernDeb+taillePhoto<posTri[i].first) {
            ans++;
            dernDeb=posTri[i].first;
        }
    }
    return ans;
}

int update(int posModif, int valNouv) {
    int pos=0;
    while (posTri[pos].second!=posModif) {
        pos++;
    }
    posTri[pos].first=valNouv;
    while (pos>0 and posTri[pos]<posTri[pos-1]) {
        swap(posTri[pos-1],posTri[pos]);
        pos--;
    }
    while (pos<nbEleph-1 and posTri[pos]>posTri[pos+1]) {
        swap(posTri[pos],posTri[pos+1]);
        pos++;
    }
    return calc();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 636 ms 8724 KB Output is correct
8 Correct 1459 ms 9564 KB Output is correct
9 Correct 1546 ms 10332 KB Output is correct
10 Correct 4226 ms 10136 KB Output is correct
11 Correct 4241 ms 10072 KB Output is correct
12 Correct 5367 ms 10072 KB Output is correct
13 Correct 4422 ms 9928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 636 ms 8724 KB Output is correct
8 Correct 1459 ms 9564 KB Output is correct
9 Correct 1546 ms 10332 KB Output is correct
10 Correct 4226 ms 10136 KB Output is correct
11 Correct 4241 ms 10072 KB Output is correct
12 Correct 5367 ms 10072 KB Output is correct
13 Correct 4422 ms 9928 KB Output is correct
14 Correct 1512 ms 10268 KB Output is correct
15 Correct 3342 ms 10216 KB Output is correct
16 Execution timed out 9061 ms 10588 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 636 ms 8724 KB Output is correct
8 Correct 1459 ms 9564 KB Output is correct
9 Correct 1546 ms 10332 KB Output is correct
10 Correct 4226 ms 10136 KB Output is correct
11 Correct 4241 ms 10072 KB Output is correct
12 Correct 5367 ms 10072 KB Output is correct
13 Correct 4422 ms 9928 KB Output is correct
14 Correct 1512 ms 10268 KB Output is correct
15 Correct 3342 ms 10216 KB Output is correct
16 Execution timed out 9061 ms 10588 KB Time limit exceeded
17 Halted 0 ms 0 KB -