Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 3,758 MiB 0,253 s OK
#2 11/11 3,758 MiB 0,186 s OK
#3 11/11 3,906 MiB 0,186 s OK
#4 11/11 3,906 MiB 0,180 s OK
#5 11/11 3,906 MiB 0,164 s OK
#6 11/11 3,906 MiB 0,188 s OK
#7 11/11 3,133 MiB 0,000 s OK
#8 11/11 3,906 MiB 0,081 s OK
#9 12/12 3,133 MiB 0,000 s OK

Ocenjevani program (main.cpp):
#include <iostream>

using namespace std;

int main() {
  int k, n;
  cin >> k >> n;
  int *t = new int[n];
  int *c = new int[n];

  long long total = 0;

  for(int i = 0; i < n; i++){
    cin >> t[i] >> c[i];
    total += c[i];
  }

  int i0 = 0, i1 = 0;
  long long sumT = 0, sumC = 0;

  long long minC = 2014700000000000L;

  while(i0 < n){
    while(sumT < k && i1 < n){
      sumT += t[i1];
      sumC += c[i1];
      i1++;
    }

    if(sumC < minC && sumT >= k){
      minC = sumC;
    }

    sumT -= t[i0];
    sumC -= c[i0];
    i0++;
  }


  if(minC == 2014700000000000L){
    cout << "Tekma bo polom" << endl;
  }else{
    cout << total - minC << endl;
  }
}