#include "elephants.h"
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
typedef long long ll;
const int MAX = 2e6 + 15;
int n, L;
vector<int> x;
void init(int n_, int l_, int x_[]){
n = n_, L = l_;
x.resize(n);
for(int i = 0; i < n; i++)
x[i] = x_[i];
}
vector<int> Merge(vector<int>& v, vector<int>& t){
vector<int> ret(sz(v) + sz(t));
merge(all(v), all(t), ret.begin());
return ret;
}
int update(int i, int y){
vector<int> l, r, m;
m.push_back(y);
for(int j = 0; j < i; j++)
l.push_back(x[j]);
for(int j = i + 1; j < sz(x); j++)
r.push_back(x[j]);
vector<int> aux1 = Merge(l, m);
vector<int> aux2 = Merge(aux1, r);
x = aux2;
int ans = 0;
for(int j = 0, t = -1; j < x.size(); j++)
if(x[j] > t) ans++, t = x[j] + L;
return ans;
}
Compilation message
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:49:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int j = 0, t = -1; j < x.size(); j++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |