#include <bits/stdc++.h>
#include "elephants.h"
//~ #include "grader.cpp"
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int n, l;
vector <pair <int, int> > a;
void init(int N, int L, int X[]){
n = N;
l = L;
for(int i = 0 ; i < n ; i++){
a.push_back(make_pair(X[i], i));
}
}
int update(int i, int y){
for(int j = 0 ; j < n ; j++){
if(a[j].second == i){
a.erase(a.begin() + j);
break;
}
}
for(int j = 0 ; j < n ; j++){
if(j == n - 1 || a[j].first > y){
a.insert(a.begin() + j, make_pair(y, i));
break;
}
}
int cur = a[0].first;
int ans = 1;
for(auto &i : a){
if(cur + l < i.first){
cur = i.first;
ans++;
}
}
return ans;
}
Compilation message
elephants.cpp:7:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("O3")
elephants.cpp:8:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2707 ms |
1280 KB |
Output is correct |
8 |
Correct |
3917 ms |
1408 KB |
Output is correct |
9 |
Correct |
4937 ms |
1780 KB |
Output is correct |
10 |
Correct |
5682 ms |
1788 KB |
Output is correct |
11 |
Correct |
5340 ms |
1788 KB |
Output is correct |
12 |
Execution timed out |
9028 ms |
1780 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2707 ms |
1280 KB |
Output is correct |
8 |
Correct |
3917 ms |
1408 KB |
Output is correct |
9 |
Correct |
4937 ms |
1780 KB |
Output is correct |
10 |
Correct |
5682 ms |
1788 KB |
Output is correct |
11 |
Correct |
5340 ms |
1788 KB |
Output is correct |
12 |
Execution timed out |
9028 ms |
1780 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2707 ms |
1280 KB |
Output is correct |
8 |
Correct |
3917 ms |
1408 KB |
Output is correct |
9 |
Correct |
4937 ms |
1780 KB |
Output is correct |
10 |
Correct |
5682 ms |
1788 KB |
Output is correct |
11 |
Correct |
5340 ms |
1788 KB |
Output is correct |
12 |
Execution timed out |
9028 ms |
1780 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |