Submission #1050235
Source Code Expand
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;
int main() {
int n;
scanf("%d", &n);
vll a(n);
rep (i, n) {
scanf("%lld", &a[i]);
}
sort(all(a));
ll sum = 0;
int cnt = 0;
rep (i, n) {
if (a[i] > sum) {
sum += a[i];
cnt += 1;
}
}
printf("%d\n", cnt);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - 鏡餅 |
User |
tspcx |
Language |
C++11 (GCC 4.8.1) |
Score |
2 |
Code Size |
1180 Byte |
Status |
AC |
Exec Time |
20 ms |
Memory |
984 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:40:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:43:25: 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 |
All |
Score / Max Score |
2 / 2 |
Status |
|
Set Name |
Test Cases |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
AC |
19 ms |
916 KB |
001.txt |
AC |
18 ms |
796 KB |
002.txt |
AC |
20 ms |
976 KB |
003.txt |
AC |
20 ms |
920 KB |
004.txt |
AC |
18 ms |
792 KB |
005.txt |
AC |
19 ms |
792 KB |
006.txt |
AC |
19 ms |
916 KB |
007.txt |
AC |
18 ms |
792 KB |
008.txt |
AC |
19 ms |
908 KB |
009.txt |
AC |
18 ms |
796 KB |
010.txt |
AC |
17 ms |
916 KB |
011.txt |
AC |
19 ms |
916 KB |
012.txt |
AC |
17 ms |
924 KB |
013.txt |
AC |
19 ms |
916 KB |
014.txt |
AC |
19 ms |
916 KB |
015.txt |
AC |
19 ms |
916 KB |
016.txt |
AC |
19 ms |
984 KB |
017.txt |
AC |
19 ms |
908 KB |
018.txt |
AC |
18 ms |
792 KB |
019.txt |
AC |
18 ms |
920 KB |
020.txt |
AC |
20 ms |
920 KB |
021.txt |
AC |
18 ms |
792 KB |
022.txt |
AC |
18 ms |
920 KB |
023.txt |
AC |
17 ms |
796 KB |
024.txt |
AC |
20 ms |
792 KB |
025.txt |
AC |
18 ms |
920 KB |
026.txt |
AC |
18 ms |
796 KB |
027.txt |
AC |
19 ms |
920 KB |
028.txt |
AC |
17 ms |
796 KB |
029.txt |
AC |
18 ms |
920 KB |
030.txt |
AC |
20 ms |
796 KB |