AtCoder Grand Contest 011

Submission #1591425

Source codeソースコード

#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

Task問題 B - Colorful Creatures
User nameユーザ名 iocto
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1116 Byte
File nameファイル名
Exec time実行時間 19 ms
Memory usageメモリ使用量 1408 KB

Compiler messageコンパイルメッセージ

./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]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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