Submission #7560458


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll sum = a[0];
    ll cnt = 1;
    ll ans = n;
    REP(i,1,n){
        if(a[i] > 2*sum){
            ans -= cnt;
            cnt = 1;
        }else{
            cnt++;
        }
        sum += a[i];
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task B - Colorful Creatures
User suta
Language C++14 (GCC 5.4.1)
Score 400
Code Size 966 Byte
Status
Exec Time 47 ms
Memory 1024 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 400 / 400 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 47 ms 1024 KB
in10.txt 15 ms 512 KB
in11.txt 39 ms 1024 KB
in12.txt 45 ms 1024 KB
in13.txt 45 ms 1024 KB
in2.txt 47 ms 1024 KB
in3.txt 47 ms 1024 KB
in4.txt 47 ms 1024 KB
in5.txt 18 ms 512 KB
in6.txt 33 ms 1024 KB
in7.txt 46 ms 1024 KB
in8.txt 33 ms 1024 KB
in9.txt 7 ms 384 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB
sample3.txt 1 ms 256 KB