Submission #1112456

#TimeUsernameProblemLanguageResultExecution timeMemory
1112456vjudge1Baloni (COCI15_baloni)C++17
100 / 100
120 ms3896 KiB
#include <iostream> #include <unordered_map> #include <vector> using namespace std; int Phsics(int n, const vector<int>& arrows) { unordered_map<int, int> count; int arrows_needed = 0; for (int arrow : arrows) { if (count[arrow] > 0) { count[arrow]--; count[arrow - 1]++; } else { arrows_needed++; count[arrow - 1]++; } } return arrows_needed; } int main() { int n; cin >> n; vector<int> arrows(n); for (int i = 0; i < n; i++) { cin >> arrows[i]; } cout << Phsics(n, arrows) << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...