AtCoder Beginner Contest 005

Submission #7462950

Source codeソースコード

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;

import org.omg.CORBA.NVList;
 
public class Main  {
	static long mod=1000000000+7;
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int T=sc.nextInt();
		int N=sc.nextInt();
		int[] A=sc.nextIntArray(N);
		int M=sc.nextInt();
		int[] B=sc.nextIntArray(M);
		boolean[] ok=new boolean[M];
		if (N<M) {
			System.out.println("no");
		}
		else {
			int k=0;
			for (int i = 0; i < M; i++) {
				while (k<N) {
					if (B[i]-A[k]<=T&&B[i]-A[k]>=0) {
						k++;
						ok[i]=true;
						break;
					}
					k++;
				}
			}
			for (int i = 0; i < ok.length; i++) {
				if (!ok[i]) {
					System.out.println("no");
					return;
				}
			}
			System.out.println("yes");
		}
	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
 
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Submission

Task問題 C - おいしいたこ焼きの売り方
User nameユーザ名 bouperson
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 3600 Byte
File nameファイル名
Exec time実行時間 71 ms
Memory usageメモリ使用量 21844 KB

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 rand0.txt,rand1.txt,rand10.txt,rand11.txt,rand12.txt,rand13.txt,rand14.txt,rand15.txt,rand16.txt,rand17.txt,rand18.txt,rand19.txt,rand2.txt,rand20.txt,rand21.txt,rand22.txt,rand23.txt,rand24.txt,rand25.txt,rand26.txt,rand27.txt,rand28.txt,rand29.txt,rand3.txt,rand4.txt,rand5.txt,rand6.txt,rand7.txt,rand8.txt,rand9.txt,s1.txt,s2.txt,s3.txt,s4.txt,s5.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
rand0.txt AC 69 ms 16980 KB
rand1.txt AC 69 ms 21204 KB
rand10.txt AC 69 ms 20564 KB
rand11.txt AC 68 ms 21204 KB
rand12.txt AC 68 ms 19156 KB
rand13.txt AC 68 ms 17364 KB
rand14.txt AC 67 ms 19540 KB
rand15.txt AC 68 ms 19156 KB
rand16.txt AC 70 ms 18260 KB
rand17.txt AC 68 ms 17364 KB
rand18.txt AC 69 ms 21076 KB
rand19.txt AC 68 ms 18516 KB
rand2.txt AC 69 ms 18388 KB
rand20.txt AC 67 ms 19284 KB
rand21.txt AC 71 ms 19152 KB
rand22.txt AC 68 ms 20180 KB
rand23.txt AC 67 ms 18004 KB
rand24.txt AC 69 ms 18644 KB
rand25.txt AC 69 ms 18260 KB
rand26.txt AC 68 ms 19412 KB
rand27.txt AC 69 ms 21204 KB
rand28.txt AC 69 ms 21076 KB
rand29.txt AC 67 ms 21332 KB
rand3.txt AC 68 ms 19540 KB
rand4.txt AC 69 ms 21844 KB
rand5.txt AC 69 ms 20052 KB
rand6.txt AC 68 ms 21332 KB
rand7.txt AC 71 ms 18900 KB
rand8.txt AC 69 ms 21332 KB
rand9.txt AC 69 ms 21076 KB
s1.txt AC 68 ms 19924 KB
s2.txt AC 68 ms 19156 KB
s3.txt AC 68 ms 18260 KB
s4.txt AC 67 ms 17620 KB
s5.txt AC 68 ms 17876 KB