Rezultati

Up. imeNalogaJezikRezultatČas oddaje
hl3-2018 Priprava naloge Java 100/100OK 19. apr '18 @ 19:17

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 101,617 MiB 1,923 s OK
#2 11/11 102,020 MiB 2,047 s OK
#3 11/11 98,648 MiB 1,899 s OK
#4 11/11 105,805 MiB 2,175 s OK
#5 11/11 103,906 MiB 1,975 s OK
#6 11/11 110,066 MiB 2,284 s OK
#7 11/11 36,680 MiB 0,000 s OK
#8 11/11 101,289 MiB 1,656 s OK
#9 12/12 25,723 MiB 0,000 s OK

Ocenjevani program (Main.java):
//package com.company;
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        long casZaNalogo = sc.nextLong();
        int n = sc.nextInt();
        sc.nextLine();
        long kcTabela [][] = new long [2][n];
        long tempC;
        long sumC = 0;
        for(int i = 0; i < n; i++){
            kcTabela[0][i] = sc.nextLong();
            tempC = sc.nextLong();
            kcTabela[1][i] = tempC;
            sumC +=tempC;
            sc.nextLine();
        }
        sc.close();
        long sumT = 0;
        long loseC = 0;
        int nxt=0;
        long minLose = sumC + 1;
        for(int i =0; i < n;i++){
            while((nxt < n) && sumT < casZaNalogo){
                sumT += kcTabela[0][nxt];
                loseC += kcTabela[1][nxt];
                nxt++;
            }
            if((sumT >= casZaNalogo) && (minLose > loseC)){
                minLose = loseC;
            }
            sumT -= kcTabela[0][i];
            loseC -= kcTabela[1][i];
        }
        if(minLose == sumC + 1){
            System.out.println("Tekma bo polom");
        }else{
            System.out.println(sumC - minLose);
        }
    }
}