Submission #2084274


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+1){
				mincost=Math.max(mincost,a[i]);
			}else{
				r+=(a[i]-1)/(mincost+1);
				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 700
Code Size 1861 Byte
Status AC
Exec Time 669 ms
Memory 63972 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 46
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 AC 669 ms 51880 KB
02.txt AC 579 ms 53216 KB
03.txt AC 604 ms 52968 KB
04.txt AC 608 ms 50884 KB
05.txt AC 542 ms 50124 KB
06.txt AC 540 ms 59776 KB
07.txt AC 547 ms 50864 KB
08.txt AC 508 ms 61588 KB
09.txt AC 534 ms 49880 KB
10.txt AC 528 ms 46872 KB
11.txt AC 510 ms 63972 KB
12.txt AC 495 ms 61444 KB
13.txt AC 571 ms 49596 KB
14.txt AC 563 ms 51680 KB
15.txt AC 591 ms 49192 KB
16.txt AC 567 ms 47020 KB
17.txt AC 558 ms 48940 KB
18.txt AC 539 ms 48108 KB
19.txt AC 605 ms 59188 KB
20.txt AC 573 ms 49376 KB
21.txt AC 535 ms 49424 KB
22.txt AC 521 ms 51428 KB
23.txt AC 555 ms 47004 KB
24.txt AC 546 ms 55484 KB
25.txt AC 567 ms 53636 KB
26.txt AC 540 ms 48808 KB
27.txt AC 571 ms 49572 KB
28.txt AC 633 ms 47016 KB
29.txt AC 512 ms 48124 KB
30.txt AC 493 ms 61924 KB
31.txt AC 466 ms 47108 KB
32.txt AC 529 ms 51420 KB
33.txt AC 544 ms 60084 KB
34.txt AC 542 ms 50028 KB
35.txt AC 535 ms 46880 KB
36.txt AC 185 ms 24780 KB
37.txt AC 171 ms 26068 KB
38.txt AC 173 ms 26192 KB
39.txt AC 178 ms 25044 KB
40.txt AC 173 ms 26836 KB
41.txt AC 195 ms 26964 KB
42.txt AC 181 ms 25292 KB
43.txt AC 171 ms 27092 KB
44.txt AC 167 ms 26708 KB
s1.txt AC 177 ms 24660 KB
s2.txt AC 181 ms 26836 KB