Submission #2855543
Source Code Expand
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b; } void run(void){ int n,k; scanf("%d%d",&n,&k); int a[50]; int i; for(i=0;i<n;i++) scanf("%d",a+i); qsort(a,n,sizeof(int),cmp); for(i=n-1;i>=0 && k>0;k-=a[i--]); if(k>0){ printf("-1\n"); } else { printf("%d\n",n-1-i); } } int main(void){ run(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Credits |
User | sansen |
Language | C (GCC 5.4.1) |
Score | 100 |
Code Size | 580 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.c: In function ‘run’: ./Main.c:17:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&k); ^ ./Main.c:20:20: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] for(i=0;i<n;i++) scanf("%d",a+i); ^
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | corner_10, corner_11, corner_12, corner_13, max_14, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, sample_00, sample_01, sample_02 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
corner_10 | AC | 1 ms | 128 KB |
corner_11 | AC | 1 ms | 128 KB |
corner_12 | AC | 1 ms | 128 KB |
corner_13 | AC | 1 ms | 128 KB |
max_14 | AC | 1 ms | 128 KB |
random_00 | AC | 1 ms | 128 KB |
random_01 | AC | 1 ms | 128 KB |
random_02 | AC | 1 ms | 128 KB |
random_03 | AC | 1 ms | 128 KB |
random_04 | AC | 1 ms | 128 KB |
random_05 | AC | 1 ms | 128 KB |
random_06 | AC | 1 ms | 128 KB |
random_07 | AC | 1 ms | 128 KB |
random_08 | AC | 1 ms | 128 KB |
random_09 | AC | 1 ms | 128 KB |
sample_00 | AC | 1 ms | 128 KB |
sample_01 | AC | 1 ms | 128 KB |
sample_02 | AC | 1 ms | 128 KB |