Submission #799940

# Submission time Handle Problem Language Result Execution time Memory
799940 2023-08-01T08:38:54 Z Sohsoh84 Dancing Elephants (IOI11_elephants) C++17
26 / 100
9000 ms 2080 KB
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")

#include "elephants.h"
#include <bits/stdc++.h>

#pragma GCC target("avx2")

using namespace std;

const int MAXN = 70000;

int X[MAXN], n, L;
int A[MAXN]; // TODO: multiset

void init(int N, int L_, int X_[]) {
	L = L_;	
	fill(A, A + MAXN, -1);
	for (int i = 0; i < N; i++) {
		X[i] = X_[i];	
		A[i] = X[i];
	}
	
	n = N;
}

int update(int i, int y) {
	int ind = lower_bound(A, A + n, X[i]) - A;
	int tx = X[i];
	X[i] = y;
	A[ind] = y;
	
	if (tx < y) {
		for (int i = 0; i < MAXN - 1; i++)
			if (A[i] > A[i + 1] && A[i + 1] != -1)
				swap(A[i], A[i + 1]);
	} else {
		for (int i = MAXN - 1; i > 0; i--) {
			if (A[i] < A[i - 1] && A[i] != -1)
				swap(A[i], A[i - 1]);
		}
	}

	int ans = 0;
	int v = -(L + 1);
	
	for (int i = 0; i < MAXN; i++) {
		if (A[i] > v + L) {
			v = A[i];
			ans++;
		}	
	}
	
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 556 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Correct 6 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 556 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Correct 6 ms 564 KB Output is correct
7 Correct 4413 ms 1540 KB Output is correct
8 Correct 5197 ms 1568 KB Output is correct
9 Correct 3320 ms 2080 KB Output is correct
10 Execution timed out 9017 ms 1780 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 556 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Correct 6 ms 564 KB Output is correct
7 Correct 4413 ms 1540 KB Output is correct
8 Correct 5197 ms 1568 KB Output is correct
9 Correct 3320 ms 2080 KB Output is correct
10 Execution timed out 9017 ms 1780 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 556 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Correct 6 ms 564 KB Output is correct
7 Correct 4413 ms 1540 KB Output is correct
8 Correct 5197 ms 1568 KB Output is correct
9 Correct 3320 ms 2080 KB Output is correct
10 Execution timed out 9017 ms 1780 KB Time limit exceeded
11 Halted 0 ms 0 KB -