Submission #808692

# Submission time Handle Problem Language Result Execution time Memory
808692 2023-08-05T09:33:21 Z Khizri Dancing Elephants (IOI11_elephants) C++17
26 / 100
9000 ms 1684 KB
#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
const int mxn=5e4+5,MAX=1e9+5;
int n,k,arr[mxn],pos[mxn],loc[mxn];
void init(int N, int L, int X[])
{
    n=N,k=L;
    for(int i=1;i<=n;i++){
        arr[i]=X[i-1]+1;
        pos[i]=i;
        loc[i]=i;
    }
}
int update(int i, int y)
{
    i++,y++;
    i=loc[i];
    arr[i]=y;
    if(arr[i]<arr[i-1]){
        int idx=i;
        while(idx>1&&arr[idx]<arr[idx-1]){
            swap(arr[idx],arr[idx-1]);
            swap(pos[idx],pos[idx-1]);
            loc[pos[idx]]=idx;
            loc[pos[idx-1]]=idx-1;
            idx--;
        }
    }
    else{
        int idx=i;
        while(idx<n&&arr[idx]>arr[idx+1]){
            swap(arr[idx],arr[idx+1]);
            swap(pos[idx],pos[idx+1]);
            loc[pos[idx]]=idx;
            loc[pos[idx+1]]=idx+1;
            idx++;
        }
    }
    int ans=1;
    int left=arr[1];
    for(int i=2;i<=n;i++){
        if(arr[i]-left>k){
            ans++;
            left=arr[i];
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1297 ms 1108 KB Output is correct
8 Correct 2396 ms 1180 KB Output is correct
9 Correct 2332 ms 1684 KB Output is correct
10 Correct 8753 ms 1680 KB Output is correct
11 Execution timed out 9030 ms 1620 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1297 ms 1108 KB Output is correct
8 Correct 2396 ms 1180 KB Output is correct
9 Correct 2332 ms 1684 KB Output is correct
10 Correct 8753 ms 1680 KB Output is correct
11 Execution timed out 9030 ms 1620 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1297 ms 1108 KB Output is correct
8 Correct 2396 ms 1180 KB Output is correct
9 Correct 2332 ms 1684 KB Output is correct
10 Correct 8753 ms 1680 KB Output is correct
11 Execution timed out 9030 ms 1620 KB Time limit exceeded
12 Halted 0 ms 0 KB -