# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1076589 | vjudge1 | Baloni (COCI15_baloni) | C++11 | 119 ms | 8640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |