# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076589 | vjudge1 | Baloni (COCI15_baloni) | C++11 | 119 ms | 8640 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>
#include <array>
using namespace std;
void scan(vector<int>&, int&);
void output(int);
int find_maximum_element(vector<int>&);
int calculate_number_of_arrows(vector<int>&, const int);
int calculate_counter_arrows(vector<int>&);
int main() {
vector<int> heights;
int size;
scan(heights, size);
output(calculate_number_of_arrows(heights, size));
}
int calculate_number_of_arrows(vector<int>& heights, const int size) {
vector<int> histogtam(find_maximum_element(heights) + 2);
for (int height : heights) {
if (histogtam[height + 1] > 0){
histogtam[height]++;
histogtam[height + 1]--;
} else {
histogtam[height]++;
}
}
return calculate_counter_arrows(histogtam);
}
int calculate_counter_arrows(vector<int>& histogram){
int counter = 0;
for (int item: histogram)
counter += item;
return counter;
}
int find_maximum_element(vector<int>& heights) {
int max = -1;
for(int height : heights) {
if (height > max) {
max = height;
}
}
return max;
}
void output(int sum) {
cout << sum;
}
void scan(vector<int>& heights, int& size){
cin >> size;
for (int counter = 0; counter < size; counter++) {
int temp;
cin >> temp;
heights.push_back(temp);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |