Submission #1778959
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define int ll typedef pair<int,int> pii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define pb emplace_back signed main(){ int n; cin>>n; vector<int> v(n); rep(i,n)cin>>v[i]; sort(all(v)); vector<int> sum(n+1,0); for(int i=1;i<=n;i++)sum[i] = v[i-1]; for(int i=1;i<=n;i++){ sum[i] += sum[i-1]; } auto solve = [&](int mid){ int t = sum[mid]; for(int i = mid;i<n;i++){ if(v[i]<=2*t){ t+=v[i]; }else{ return false; } } return true; }; ll left=0, right=n, mid=(left+right)/2LL; while(left+1<right){ bool res = solve(mid); if(!res) left = mid; else right= mid; mid = (left+right)/2LL; } cout<<n-mid<<endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Creatures |
User | Yazaten |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 993 Byte |
Status | AC |
Exec Time | 49 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 48 ms | 1792 KB |
in10.txt | AC | 15 ms | 896 KB |
in11.txt | AC | 41 ms | 1792 KB |
in12.txt | AC | 49 ms | 1792 KB |
in13.txt | AC | 45 ms | 1792 KB |
in2.txt | AC | 48 ms | 1792 KB |
in3.txt | AC | 48 ms | 1792 KB |
in4.txt | AC | 48 ms | 1792 KB |
in5.txt | AC | 19 ms | 896 KB |
in6.txt | AC | 33 ms | 1792 KB |
in7.txt | AC | 47 ms | 1792 KB |
in8.txt | AC | 33 ms | 1792 KB |
in9.txt | AC | 9 ms | 384 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |