Submission #1076589

#TimeUsernameProblemLanguageResultExecution timeMemory
1076589vjudge1Baloni (COCI15_baloni)C++11
100 / 100
119 ms8640 KiB
#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 timeMemoryGrader output
Fetching results...