# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
919886 | vjudge1 | Monkey and Apple-trees (IZhO12_apple) | C++17 | 1 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
int main() {
int M;
std::cin >> M;
std::vector<bool> ripen; // true if apple tree is red-ripen, false otherwise
int C = 0; // the amount of red-ripen apple-trees Chris has counted
while (M--) {
int D, X, Y;
std::cin >> D >> X >> Y;
if (D == 1) { // Chris's arrival
int count = 0;
for (int i = X + C - 1; i <= Y + C - 1; i++) {
if (ripen[i]) {
count++;
}
}
std::cout << count << std::endl;
C = count;
} else if (D == 2) { // red-ripening of apple-trees
for (int i = X + C - 1; i <= Y + C - 1; i++) {
ripen[i] = true;
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |