#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
vector<int> isABegin;
vector<pair<int,int>> listOfBegins;
set<pair<int,int>> pos;
int L;
void init(int N, int L_, int X[]) {
L = L_;
n = N;
a.resize(n);
isABegin.resize(n);
for(int i = 0; i < n; i++) {
a[i] = X[i];
// pos.insert({a[i], i});
}
}
bool first = 1;
int update(int i, int y) {
// pos.erase(make_pair(a[i], i));
a[i] = y;
// pos.insert(make_pair(a[i], i));
vector<pair<int,int>> pos(n);
for(int i = 0; i < n; i++)
pos[i] = {a[i], i};
sort(pos.begin(), pos.end());
auto it = pos.begin();
int l = it->first + L+1;
int ans = 1;
for(auto p: pos) {
int i = p.second;
int x = p.first;
if(x >= l) {
l = x + L + 1;
ans++;
}
}
return ans;
}
Compilation message
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:41:7: warning: unused variable 'i' [-Wunused-variable]
int i = p.second;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
9069 ms |
1144 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
9069 ms |
1144 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
9069 ms |
1144 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |