提出 #54337150
ソースコード 拡げる
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int N = Integer.parseInt(sc.next());
int M = Integer.parseInt(sc.next());
int[] hands = new int[N];
int handsCount = 0;
int count = 0;
for (int i = 0; i < N; i++) {
int temp = Integer.parseInt(sc.next());
hands[i] = temp;
handsCount += temp;
if (handsCount > M) {
break;
}
count++;
}
System.out.println(count);
}
public static boolean areCoprime(int a, int b) {
return gcd(a, b) == 1;
}
public static int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
public static int lcm(int a, int b) {
return (a * (b / gcd(a, b)));
}
}
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte()) {
return buffer[ptr++];
} else {
return -1;
}
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
ptr++;
}
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) {
throw new NoSuchElementException();
}
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Sanitize Hands |
| ユーザ | andrywawa |
| 言語 | Java (OpenJDK 17) |
| 得点 | 100 |
| コード長 | 3257 Byte |
| 結果 | AC |
| 実行時間 | 40 ms |
| メモリ | 34212 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 100 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_00.txt | AC | 37 ms | 34024 KiB |
| example_01.txt | AC | 38 ms | 33948 KiB |
| example_02.txt | AC | 36 ms | 34120 KiB |
| hand_00.txt | AC | 39 ms | 34212 KiB |
| hand_01.txt | AC | 37 ms | 33936 KiB |
| hand_02.txt | AC | 40 ms | 34152 KiB |
| hand_03.txt | AC | 37 ms | 34172 KiB |
| hand_04.txt | AC | 37 ms | 34096 KiB |
| hand_05.txt | AC | 37 ms | 34168 KiB |
| random_00.txt | AC | 36 ms | 34012 KiB |
| random_01.txt | AC | 37 ms | 34160 KiB |
| random_02.txt | AC | 38 ms | 33908 KiB |
| random_03.txt | AC | 40 ms | 34000 KiB |
| random_04.txt | AC | 38 ms | 34080 KiB |
| random_05.txt | AC | 39 ms | 33944 KiB |
| random_06.txt | AC | 37 ms | 33892 KiB |
| random_07.txt | AC | 38 ms | 33956 KiB |
| random_08.txt | AC | 40 ms | 33960 KiB |
| random_09.txt | AC | 37 ms | 33928 KiB |