Submission #1181782

#TimeUsernameProblemLanguageResultExecution timeMemory
1181782random_nameDischarging (NOI20_discharging)C++20
0 / 100
240 ms8244 KiB
#include <bits/stdc++.h> using namespace std; #define long long long #pragma region overloadings template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1, T2>& pair){ os << '(' << pair.first << ", " << pair.second << ')'; return os; } template <typename T1, typename T2> ostream& operator<< (ostream& os, const map<T1, T2>& map_var){ for(pair<T1, T2> i: map_var){ os << '(' << i.first << ": " << i.second << ") "; } return os; } template <typename T> ostream& operator<< (ostream& os, const vector<T>& vec){ for(T i: vec) os << i << ' '; return os; } template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1, T2>& pair){ is >> pair.first >> pair.second; return is; } template <typename T> istream& operator>> (istream& is, vector<T>& vec){ for(int i = 0; i < vec.size(); i++) is >> vec[i]; return is; } #pragma endregion bool test_cases = false; ifstream ifile; ofstream ofile; // #define cin ifile // #define cout ofile void solution(){ int n; cin >> n; vector<long> A(n); cin >> A; // Non decreasing long arr_max = 0; for(int i = 0; i < n; i++){ arr_max = max(arr_max, A[i]); A[i] = arr_max; } map<int, int> c_arr; for(int i = 0; i < n; i++){ c_arr[A[i]]++; } for(int i = n-2; i >= 0; i--){ long merge = c_arr[A[i]] * (A[i+1] - A[i]); long split = (n-i-1) * (A[i]); if(merge < split && A[i] != A[i+1]){ c_arr[A[i+1]] += c_arr[A[i]]; c_arr[A[i]] = 0; } } cout << c_arr; } int main(){ ifile.open("circlecross.in"); ofile.open("circlecross.out"); if(test_cases){ int t; cin >> t; while(t--){ solution(); } } else{ solution(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...