Submission #1157568
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;
int N;
bool f(int m,vector<ll>& A)
{
deque<bool> used(N);
ll curr = A [m];
used [m] = true;
FOR(i,0,N) if(used [i] == false){
if(curr * 2 >= A [i]){
curr += A [i];
used [i] = true;
}
else{
return false;
}
}
return true;
}
int main()
{
scanf("%d",&N);
vector<ll> A(N);
FOR(i,0,N){
scanf("%lld",&A [i]);
}
sort(ALL(A));
int ng = -1,ok = N - 1,mid;
while(ok - ng > 1){
mid = (ok + ng) / 2;
if(f(mid,A)){
ok = mid;
}
else{
ng = mid;
}
}
printf("%d\n",N - ok);
return 0;
}
Submission Info
Submission Time
2017-03-12 21:37:48+0900
Task
B - Colorful Creatures
User
gigime
Language
C++14 (GCC 5.4.1)
Score
400
Code Size
917 Byte
Status
AC
Exec Time
25 ms
Memory
1152 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:31:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&N);
^
./Main.cpp:34:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&A [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
25 ms
1152 KB
in10.txt
AC
10 ms
640 KB
in11.txt
AC
22 ms
1152 KB
in12.txt
AC
19 ms
1152 KB
in13.txt
AC
18 ms
1152 KB
in2.txt
AC
25 ms
1152 KB
in3.txt
AC
25 ms
1152 KB
in4.txt
AC
24 ms
1152 KB
in5.txt
AC
10 ms
640 KB
in6.txt
AC
22 ms
1152 KB
in7.txt
AC
23 ms
1152 KB
in8.txt
AC
21 ms
1152 KB
in9.txt
AC
4 ms
384 KB
sample1.txt
AC
1 ms
256 KB
sample2.txt
AC
1 ms
256 KB
sample3.txt
AC
1 ms
256 KB