Submission #1591425
Source Code Expand
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v) sort(v.begin(), v.end())
#define SORTFUNC(v, func) sort(v.begin(), v.end(), func)
#define PRINT(v) REP(i, v.size()) printf("%d ", v[i]); cout << endl
#define IN(n) scanf("%d", &(n))
int main(){
int n;
IN(n);
vector<int> tab(n);
REP(i, n) IN(tab[i]);
SORT(tab);
ll sum[100000];
sum[0] = tab[0];
FOR(i, 1, n) sum[i] = tab[i] + sum[i-1];
int res = 1;
for(int i = n-2; i >= 0; i--){
if (2*sum[i] >= tab[i+1]) res++;
else break;
}
printf("%d\n", res);
return 0;
}
// I'd like to scroll past the end of document using Atom but I seemigly have to use these blank lines instead
Submission Info
Submission Time |
|
Task |
B - Colorful Creatures |
User |
iocto |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1116 Byte |
Status |
AC |
Exec Time |
19 ms |
Memory |
1408 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
IN(n);
^
./Main.cpp:31:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, n) IN(tab[i]);
^
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 |
19 ms |
1408 KB |
in10.txt |
AC |
8 ms |
768 KB |
in11.txt |
AC |
18 ms |
1408 KB |
in12.txt |
AC |
15 ms |
1408 KB |
in13.txt |
AC |
15 ms |
1408 KB |
in2.txt |
AC |
19 ms |
1408 KB |
in3.txt |
AC |
19 ms |
1408 KB |
in4.txt |
AC |
19 ms |
1408 KB |
in5.txt |
AC |
8 ms |
640 KB |
in6.txt |
AC |
16 ms |
1408 KB |
in7.txt |
AC |
19 ms |
1408 KB |
in8.txt |
AC |
16 ms |
1408 KB |
in9.txt |
AC |
3 ms |
384 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |