Submission #1157583


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
using ll=long long;

int main() {
  int n; cin >> n;
  vector<int> A(n);
  vector<ll> psum;
  ll cur = 0;
  
  for(int &a:A) cin >> a;
  sort(A.begin(), A.end());
  for(int a:A) {
    cur += a;
    psum.push_back(cur);
  }

  int res;

  for(int i = 0; i < n; i++) {
    cur = psum[i];
    int j = i+1;
    while(j < n) {
      if(cur*2 >= A[j]) {
        cur += A[j];
        j++;
      }
      else break;
    }
    if (j == n) res++;
  }

  cout << res << endl;

  return 0;
}

Submission Info

Submission Time
Task B - Colorful Creatures
User icchyr
Language C++14 (GCC 5.4.1)
Score 0
Code Size 564 Byte
Status TLE
Exec Time 2103 ms
Memory 1784 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 10
TLE × 9
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 TLE 2103 ms 1784 KB
in10.txt AC 357 ms 1020 KB
in11.txt AC 1662 ms 1784 KB
in12.txt TLE 2103 ms 1784 KB
in13.txt TLE 2103 ms 1784 KB
in2.txt TLE 2103 ms 1784 KB
in3.txt TLE 2103 ms 1784 KB
in4.txt TLE 2103 ms 1784 KB
in5.txt AC 493 ms 1020 KB
in6.txt TLE 2103 ms 1784 KB
in7.txt TLE 2103 ms 1784 KB
in8.txt TLE 2103 ms 1784 KB
in9.txt AC 53 ms 512 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB