Submission #779341


Source Code Expand

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;

class Main{
	
	public Main(){}
	
	public void run(){
		try{
			Scanner s = new Scanner();
			long a = s.nextLong();
			long b = s.nextLong();
			long k = s.nextLong();
			long l = s.nextLong();
			long amari = k % l;
			long n = (k-amari)/l;
			long value = amari*a+n*b;
			k = k - amari + l;
			if(value>(k/l*b))value = k/l*b;
			System.out.println(value);
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public static void main(String[] argv){
		Main main = new Main();
		main.run();
	}
	
	private class Scanner{
		private int p;
		private BufferedReader br;
		String regex = " ";
		String[] token;

		public Scanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
			p = -1;
			token = new String[0];
		}
		
		void setRegex(String str){
			this.regex = str;
		}
		
		void reset(){
			p = -1;
			token = new String[0];
		}
		
		String next() throws IOException{
			if(p < 0){
				String line = br.readLine();
				while("".equals(line))line = br.readLine();
				token = line.split(regex,0);
				p = 0;
				return token[p++];
			}else{
				if(p<token.length)return token[p++];
				p = -1;
				return null;
			}
		}
	
		int nextInt() throws NumberFormatException, IOException{
			return Integer.parseInt(next());
		}
		
		long nextLong() throws NumberFormatException, IOException{
			return Long.parseLong(next());
		
		}
		
		double nextDouble() throws NumberFormatException, IOException{
			return Double.parseDouble(next());
		}
		
		String nextString() throws NumberFormatException, IOException{
			return next();	
		}		
	}
}

Submission Info

Submission Time
Task A - みんなでワイワイみかん
User shopon1201
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 1791 Byte
Status AC
Exec Time 199 ms
Memory 8020 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 12
Set Name Test Cases
Sample sample0.txt, sample1.txt, sample2.txt, sample3.txt
All subtask0_0.txt, subtask0_1.txt, subtask0_10.txt, subtask0_11.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt
Case Name Status Exec Time Memory
sample0.txt AC 153 ms 8020 KiB
sample1.txt AC 159 ms 8012 KiB
sample2.txt AC 155 ms 7892 KiB
sample3.txt AC 154 ms 7888 KiB
subtask0_0.txt AC 159 ms 7892 KiB
subtask0_1.txt AC 150 ms 8020 KiB
subtask0_10.txt AC 159 ms 8016 KiB
subtask0_11.txt AC 151 ms 7888 KiB
subtask0_2.txt AC 151 ms 8020 KiB
subtask0_3.txt AC 199 ms 7892 KiB
subtask0_4.txt AC 143 ms 7892 KiB
subtask0_5.txt AC 155 ms 7892 KiB
subtask0_6.txt AC 151 ms 7892 KiB
subtask0_7.txt AC 151 ms 8020 KiB
subtask0_8.txt AC 151 ms 7888 KiB
subtask0_9.txt AC 160 ms 7892 KiB