Submission #583575

# Submission time Handle Problem Language Result Execution time Memory
583575 2022-06-25T15:44:26 Z benson1029 Dancing Elephants (IOI11_elephants) C++14
26 / 100
9000 ms 1692 KB
#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int n;
int l;
pair<int,int> x[150005];
int pos[150005];

void init(int N, int L, int X[])
{
	n = N;
	l = L;
	for(int i=0; i<n; i++) {
		x[i] = make_pair(X[i], i);
	}
	sort(x, x+n);
	for(int i=0; i<n; i++) {
		pos[x[i].second] = i;
	}
}

int update(int i, int y)
{
	int ptr = pos[i];
	x[ptr].first = y;
	while(ptr > 0 && x[ptr] < x[ptr-1]) {
		swap(pos[x[ptr].second], pos[x[ptr-1].second]);
		swap(x[ptr], x[ptr-1]);
		--ptr;
	}
	while(ptr < n-1 && x[ptr] > x[ptr+1]) {
		swap(pos[x[ptr].second], pos[x[ptr+1].second]);
		swap(x[ptr], x[ptr+1]);
		++ptr;
	}
	int past = x[0].first;
	int ans = 1;
	for(int i=1; i<n; i++) {
		if(past+l < x[i].first) {
			ans++;
			past = x[i].first;
		}
	}
	return ans;
}

Compilation message

elephants.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
elephants.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      |
# 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 1 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 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 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 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1937 ms 1108 KB Output is correct
8 Correct 2865 ms 1184 KB Output is correct
9 Correct 3680 ms 1692 KB Output is correct
10 Execution timed out 9028 ms 1612 KB Time limit exceeded
11 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 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1937 ms 1108 KB Output is correct
8 Correct 2865 ms 1184 KB Output is correct
9 Correct 3680 ms 1692 KB Output is correct
10 Execution timed out 9028 ms 1612 KB Time limit exceeded
11 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 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1937 ms 1108 KB Output is correct
8 Correct 2865 ms 1184 KB Output is correct
9 Correct 3680 ms 1692 KB Output is correct
10 Execution timed out 9028 ms 1612 KB Time limit exceeded
11 Halted 0 ms 0 KB -