Submission #248549

#TimeUsernameProblemLanguageResultExecution timeMemory
248549A02Dancing Elephants (IOI11_elephants)C++14
26 / 100
9082 ms3072 KiB
#include "elephants.h" #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <set> #include <utility> using namespace std; int n; long long l; vector<long long> elephant_positions; set<long long> sorted_elephant_set; void init(int N, int L, int X[]) { n = N; l = L; for (int i = 0; i < N; i++){ elephant_positions.push_back(X[i]); sorted_elephant_set.insert(X[i]); } } int update(int i, int y) { sorted_elephant_set.erase(elephant_positions[i]); sorted_elephant_set.insert(y); elephant_positions[i] = y; long long current_start = -2 * l; long long current_cameras = 0; for (set<long long>::iterator it = sorted_elephant_set.begin(); it != sorted_elephant_set.end(); it++){ if (*(it) - current_start > l){ current_start = *(it); current_cameras++; } } return current_cameras; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...