Submission #1156781
Source Code Expand
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
int main(){
int n;
static ll a[100010];
scanf("%d",&n);
rep(i,n)scanf("%lld",&a[i]);
vector<ll> A;
rep(i,n)A.pb(a[i]);
sor(A);
static ll s[100010];
s[0] = A[0];
for(int i = 1 ; i < n ; i++){
s[i] = s[i-1] + A[i];
}
for(int i = n-2 ; i >= 0 ; i --){
if(s[i]*2 < A[i+1]){
cout << n-i-1 << endl;
return 0;
}
}
cout << n << endl;
}
Submission Info
Submission Time
2017-03-12 21:15:41+0900
Task
B - Colorful Creatures
User
yokozuna57
Language
C++14 (GCC 5.4.1)
Score
400
Code Size
1393 Byte
Status
AC
Exec Time
20 ms
Memory
2676 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:40:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:41:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n)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
20 ms
2676 KB
in10.txt
AC
8 ms
1272 KB
in11.txt
AC
19 ms
2676 KB
in12.txt
AC
16 ms
2676 KB
in13.txt
AC
16 ms
2676 KB
in2.txt
AC
20 ms
2676 KB
in3.txt
AC
20 ms
2676 KB
in4.txt
AC
20 ms
2676 KB
in5.txt
AC
8 ms
1272 KB
in6.txt
AC
17 ms
2676 KB
in7.txt
AC
20 ms
2676 KB
in8.txt
AC
17 ms
2676 KB
in9.txt
AC
3 ms
640 KB
sample1.txt
AC
1 ms
256 KB
sample2.txt
AC
1 ms
256 KB
sample3.txt
AC
1 ms
256 KB