Submission #1694277
Source Code Expand
import java.io.*; import java.util.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); int x = ni(); int[] a = new int[n]; int min = Integer.MAX_VALUE; int s = 0; for(int i = 0; i < n; i++){ a[i] = ni(); if(a[i] < min){ s = i; min = a[i]; } } long time = min; int cur = s; while(true){ cur = (cur+1)%n; if(cur == s) break; if(a[cur] > min+x){ time += min+x; } else{ time += a[cur]; } } out.println(time); } void run() throws Exception { is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms"); } public static void main(String[] args) throws Exception { new Main().run(); } private byte[] inbuf = new byte[1024]; private int lenbuf = 0, ptrbuf = 0; private int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char)skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b) && b != ' ')){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | yuya178 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 3966 Byte |
Status | WA |
Exec Time | 85 ms |
Memory | 21716 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.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, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 70 ms | 21200 KB |
0_01.txt | AC | 68 ms | 20436 KB |
0_02.txt | AC | 67 ms | 20308 KB |
1_00.txt | AC | 69 ms | 18900 KB |
1_01.txt | AC | 70 ms | 20308 KB |
1_02.txt | AC | 74 ms | 20820 KB |
1_03.txt | AC | 85 ms | 21716 KB |
1_04.txt | AC | 70 ms | 20180 KB |
1_05.txt | AC | 72 ms | 21332 KB |
1_06.txt | WA | 71 ms | 21460 KB |
1_07.txt | AC | 82 ms | 21332 KB |
1_08.txt | WA | 73 ms | 21332 KB |
1_09.txt | AC | 70 ms | 21332 KB |
1_10.txt | AC | 71 ms | 17108 KB |
1_11.txt | WA | 73 ms | 18900 KB |
1_12.txt | WA | 70 ms | 20308 KB |
1_13.txt | WA | 71 ms | 19284 KB |
1_14.txt | WA | 79 ms | 21332 KB |
1_15.txt | WA | 71 ms | 18004 KB |
1_16.txt | WA | 71 ms | 20692 KB |
1_17.txt | WA | 71 ms | 18644 KB |