Changed the folder structure of codeforces problemsets
This commit is contained in:
39
codeforces/problemsets/twins/twins.cpp
Normal file
39
codeforces/problemsets/twins/twins.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t, c, sum=0;
|
||||
cin >> t;
|
||||
|
||||
vector<int> coins;
|
||||
|
||||
for(int n = 0; n < t; n++){
|
||||
cin >> c;
|
||||
sum += c;
|
||||
coins.push_back(c);
|
||||
}
|
||||
|
||||
sort(coins.begin(), coins.end());
|
||||
reverse(coins.begin(), coins.end());
|
||||
|
||||
float half = (float)sum / 2;
|
||||
int acc = 0, result = 0;
|
||||
for(int& i : coins){
|
||||
acc += i;
|
||||
result++;
|
||||
if(acc > half){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user