Submission #3444042
Source Code Expand
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #define ll long long #define MAXN 105 using namespace std; typedef pair<int,int> pii; template <typename t> inline void read(t& a) { t ret(0),f(1);char ch(getchar()); while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();} while(ch >= '0' && ch <= '9'){ret = ret * 10 + (ch ^ 48);ch = getchar();} a = ret * f; } inline int Max(int x,int y){return x > y ? x : y;} inline int Min(int x,int y){return x < y ? x : y;} int a[MAXN]; int main() { int n,x,ans(0); read(n),read(x); for(int i(1);i <= n;i++) read(a[i]); sort(a + 1,a + n + 1); for(int i(1);i <= n;i++) { if(x >= a[i]) x -= a[i],++ans; else {x = 0;break;} } printf("%d",Max(0,ans - (x != 0))); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Candy Distribution Again |
User | PrimeMinister |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 814 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 128 KB |
0_01.txt | AC | 0 ms | 128 KB |
0_02.txt | AC | 0 ms | 128 KB |
0_03.txt | AC | 0 ms | 128 KB |
1_00.txt | AC | 0 ms | 128 KB |
1_01.txt | AC | 0 ms | 128 KB |
1_02.txt | AC | 2 ms | 256 KB |
1_03.txt | AC | 1 ms | 128 KB |
1_04.txt | AC | 1 ms | 128 KB |
1_05.txt | AC | 1 ms | 128 KB |
1_06.txt | AC | 1 ms | 128 KB |
1_07.txt | AC | 1 ms | 128 KB |