Untitled
unknown
plain_text
a year ago
1.2 kB
2
Indexable
Never
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int func(vector<int>&nums) { unordered_map<int,vector<int>>mpp; int ans=0; vector<pair<int,int>>n; for(int i=0;i<nums.size();i++) { n.push_back({nums[i],nums[i]}); mpp[nums[i]].push_back(i); } for(int i=0;i<n.size();i++) { ans+=n[i].second; int k=n[i].first; for(auto&x:mpp[k]) { if(x>i) n[x].second=ceil((n[x].second)/2.0); } } return ans; } int main() { int n; cin>>n; vector<int>nums; for(int i=0;i<n;i++) { int x; cin>>x; nums.push_back(x); } cout<<func(nums); return 0; }