Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ASMx64-2018 Priprava naloge C++ 100/100OK 19. apr '18 @ 18:00

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 4,660 MiB 0,301 s OK
#2 11/11 4,520 MiB 0,210 s OK
#3 11/11 4,520 MiB 0,204 s OK
#4 11/11 4,520 MiB 0,210 s OK
#5 11/11 4,660 MiB 0,194 s OK
#6 11/11 4,660 MiB 0,194 s OK
#7 11/11 3,145 MiB 0,004 s OK
#8 11/11 4,516 MiB 0,075 s OK
#9 12/12 3,020 MiB 0,000 s OK

Ocenjevani program (priprava.cpp):
//============================================================================
// Name        : priprava.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

long long k, n, casiDog[100001], pomemb[100001];
long long vsota = 0, minvsota = 1000000000000000000LL;
int start = 0, konec = 0;
int startO = 0, konecO = 0;

int konec_opravila(int start) {
while (casiDog[konec]-casiDog[start]<k){
	konec++;
	if (konec>n) return -1;
}
return konec;
	/*
	if (startO!=0)
		vsota-=pomemb[startO-1];
	int temp = konecO;
	while (konec - start < k && temp < n) {
		konec = casiDog[temp+1];
		temp++;
	}
	start+=casiDog[startO-1];
	if (temp >= n)
		return -1;
	else
		return temp;*/
}

int main() {
	cin >> k >> n;

	casiDog[0] = 0;
	pomemb[0]=0;
	for (int i = 1; i <= n; i++) {
		cin >> casiDog[i] >> pomemb[i];
		casiDog[i]+=casiDog[i-1];
		pomemb[i] += pomemb[i - 1];
	}

	if(k > casiDog[n]){
		cout << "Tekma bo polom";
		return 0;
	}
	/*int check = 0, checkD = 0;
	while (check < k && checkD < n) {
		check += casiDog[checkD];
		checkD++;
	}
	if (checkD >= n) {
		cout << "Polomija";
		return 0;
	}*/


	int index = 0, temp;
	while (true) {
		temp = konec_opravila(index);

		if (temp == -1) {
			break;
		}

		//cout <<casiDog[index] << casiDog[temp] << endl;
		vsota=pomemb[temp]-pomemb[index];
		//for (int i = konecO; i < temp; i++) {
			//vsota += pomemb[i];
	 index++;
		//cout << start << endl << konec<<endl;

		if (vsota < minvsota)
			minvsota = vsota;

	}
	if(minvsota == 1000000000000000000LL) cout << 0;
	else cout << pomemb[n]-minvsota;

	return 0;
}