Submission #3201933
Source Code Expand
import java.lang.*;
import java.io.*;
import java.util.*;
class Main{
public static void main(String args[]) throws FileNotFoundException{
FScanner sc=new FScanner();
//Scanner sc=new Scanner(System.in);
int[] num=sc.readIntL();
int[] chl=sc.readIntL();
int itm=num[1];
int cnt=0;
int pay=0;
Arrays.sort(chl);
for(int i=0; i<chl.length-1; i++){
//System.out.printf("%d/%d\n",itm,chl[i]);
if(itm>0 && itm>=chl[i]){
itm-=chl[i];
cnt+=1;
}
}
//System.out.printf("%d/%d\n",itm,chl[chl.length-1]);
if(itm>0 && itm==chl[chl.length-1]){
cnt+=1;
}
System.out.println(cnt);
}
static void solve(){}
static void disp(int[] data){
for(int i=0; i<data.length; i++){
System.out.printf("%d ",data[i]);
}
System.out.println();
}
static void disp(String[] data){
for(int i=0; i<data.length; i++){
System.out.printf("%s ",data[i]);
}
System.out.println();
}
static class FScanner{
Scanner sc;
FScanner() throws FileNotFoundException{
sc=new Scanner(System.in);
}
boolean hasNextLine(){
boolean has=true;
if(!sc.hasNextLine()){
has=false;
}
return has;
}
int readInt(){
String buf=sc.nextLine();
return Integer.parseInt(buf);
}
long readLong(){
long i=Long.parseLong(sc.nextLine());
return i;
}
int[] readIntL(){
String[] buf=sc.nextLine().split(" ");
int[] num=new int[buf.length];
for(int i=0; i<buf.length; i++){
num[i]=Integer.parseInt(buf[i]);
}
return num;
}
String readString(){
return sc.nextLine();
}
String[] readStringL(String dlm){
String[] s=sc.nextLine().split(dlm);
return s;
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Candy Distribution Again |
| User | tokumei_jp |
| Language | Java8 (OpenJDK 1.8.0) |
| Score | 200 |
| Code Size | 1743 Byte |
| Status | AC |
| Exec Time | 106 ms |
| Memory | 21844 KiB |
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 | 92 ms | 21204 KiB |
| 0_01.txt | AC | 92 ms | 20948 KiB |
| 0_02.txt | AC | 92 ms | 21844 KiB |
| 0_03.txt | AC | 92 ms | 21460 KiB |
| 1_00.txt | AC | 92 ms | 20692 KiB |
| 1_01.txt | AC | 95 ms | 20820 KiB |
| 1_02.txt | AC | 94 ms | 21076 KiB |
| 1_03.txt | AC | 95 ms | 19028 KiB |
| 1_04.txt | AC | 94 ms | 20688 KiB |
| 1_05.txt | AC | 105 ms | 19028 KiB |
| 1_06.txt | AC | 106 ms | 19924 KiB |
| 1_07.txt | AC | 96 ms | 19796 KiB |