Submission #2077369
Source Code Expand
import java.util.Arrays; import java.util.Iterator; import java.util.PrimitiveIterator; import java.util.Scanner; import java.util.stream.IntStream; import java.util.stream.Stream; class Main{ private void solve(){ int n=gInt(); int[]a=ints(n).toArray(); long r=a[0]-1; a[0]=1; int mincost=1; for(int i=1;i<n;++i) { if(a[i]<=mincost){ mincost=Math.max(mincost,a[i]+1); }else{ r+=(a[i]-1)/mincost; a[i]=1; } } System.out.println(r); System.err.println(Arrays.toString(a)); } public static void main(String[]$){ new Main().solve(); } static Scanner s=new Scanner(System.in); static int gInt(){ return s.nextInt(); } static long gLong(){ return s.nextLong(); } static long gDouble(){ return s.nextLong(); } static Range rep(int i){ return new Range(i); } static Range rep(int f,int t,int d){ return new Range(f,t,d); } static Range rep(int f,int t){ return rep(f,t,1); } static Range rrep(int f,int t){ return rep(f,t,-1); } static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{ int to,cur,d; Range(int from,int to,int d){ this.cur=from-d; this.to=to; this.d=d; } Range(int n){ this(0,n-1,1); } @Override public Iterator<Integer> iterator(){ return this; } @Override public boolean hasNext(){ return cur+d==to||(cur!=to&&(cur<to==cur+d<to)); } @Override public int nextInt(){ return cur+=d; } } static IntStream REPS(int v){ return IntStream.range(0,v); } static IntStream REPS(int l,int r){ return IntStream.rangeClosed(l,r); } static IntStream ints(int n){ return REPS(n).map(i->gInt()); } static Stream<String> strs(int n){ return REPS(n).mapToObj(i->s.next()); } }
Submission Info
Submission Time | |
---|---|
Task | D - Greedy customers |
User | fal_rnd |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1857 Byte |
Status | WA |
Exec Time | 601 ms |
Memory | 62984 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 578 ms | 47484 KB |
02.txt | WA | 584 ms | 51336 KB |
03.txt | WA | 584 ms | 49324 KB |
04.txt | WA | 570 ms | 50864 KB |
05.txt | WA | 532 ms | 48408 KB |
06.txt | WA | 542 ms | 51360 KB |
07.txt | WA | 536 ms | 50636 KB |
08.txt | WA | 532 ms | 49048 KB |
09.txt | WA | 534 ms | 44584 KB |
10.txt | WA | 524 ms | 48220 KB |
11.txt | WA | 476 ms | 62984 KB |
12.txt | WA | 537 ms | 48332 KB |
13.txt | WA | 556 ms | 49936 KB |
14.txt | WA | 561 ms | 49340 KB |
15.txt | WA | 550 ms | 51136 KB |
16.txt | WA | 546 ms | 51220 KB |
17.txt | AC | 600 ms | 48036 KB |
18.txt | WA | 557 ms | 49784 KB |
19.txt | WA | 567 ms | 49324 KB |
20.txt | WA | 561 ms | 48212 KB |
21.txt | WA | 524 ms | 50372 KB |
22.txt | WA | 559 ms | 49392 KB |
23.txt | WA | 549 ms | 50780 KB |
24.txt | WA | 531 ms | 49308 KB |
25.txt | WA | 546 ms | 47772 KB |
26.txt | WA | 525 ms | 49628 KB |
27.txt | WA | 555 ms | 47800 KB |
28.txt | WA | 601 ms | 53256 KB |
29.txt | AC | 520 ms | 48440 KB |
30.txt | WA | 529 ms | 49336 KB |
31.txt | WA | 483 ms | 49564 KB |
32.txt | WA | 556 ms | 51060 KB |
33.txt | WA | 570 ms | 48844 KB |
34.txt | AC | 563 ms | 50120 KB |
35.txt | WA | 518 ms | 48452 KB |
36.txt | AC | 182 ms | 24276 KB |
37.txt | AC | 171 ms | 24400 KB |
38.txt | AC | 171 ms | 26708 KB |
39.txt | WA | 181 ms | 24784 KB |
40.txt | WA | 186 ms | 23500 KB |
41.txt | WA | 174 ms | 26196 KB |
42.txt | WA | 170 ms | 26452 KB |
43.txt | WA | 170 ms | 29140 KB |
44.txt | AC | 171 ms | 26324 KB |
s1.txt | WA | 176 ms | 24784 KB |
s2.txt | AC | 176 ms | 25172 KB |