Rezultati

Up. imeNalogaJezikRezultatČas oddaje
Deathmask Priprava naloge C++ 100/100OK 19. apr '18 @ 19:51

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 4,520 MiB 0,216 s OK
#2 11/11 4,660 MiB 0,210 s OK
#3 11/11 4,520 MiB 0,216 s OK
#4 11/11 4,520 MiB 0,198 s OK
#5 11/11 4,656 MiB 0,170 s OK
#6 11/11 4,656 MiB 0,176 s OK
#7 11/11 2,992 MiB 0,000 s OK
#8 11/11 4,660 MiB 0,087 s OK
#9 12/12 3,008 MiB 0,000 s OK

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

using namespace std;

int main()
{
    int n;

    int ts;

    cin>>ts>>n;
     long time[n],worth[n];

    for (int i=0;i<n;i++)
    {
        cin>>time[i];
        cin>>worth[i];
    }
    long tmp=0;
    long  total=0;
bool valid=true;
        long sum=0;
        long  tim=0;
int i=0,j=0;
    for (int i=0;i<n;i++)
    {
        total+=worth[i];
    }



  do
{



	while (tim<ts){
		if (j==n)
		{
			if (i==0)
                        {
                     cout<<"Tekma bo polom";
                        return 0;
                         }
			break;
		}

		tim+=time[j];
		sum+=worth[j];
		j++;
		//cout<< "w1 "<< i<<" "<<j<<" "<<sum<<" "<<tim<<endl;
	}

	if (i==0 or sum<tmp and tim>=ts)
		tmp=sum;

		while (tim>=ts and i!=j)
		{
			tim-=time[i];
			sum-=worth[i];
			i++;
			if (sum<tmp and tim>=ts)
				tmp=sum;
			//cout<< "w2 "<< i<<" "<<j<<" "<<sum<<" "<<tim<<endl;
		}

		if (j>n-1 and tim<ts )
            break;

}
while (i!=j or j!=n-1);



cout<<total-tmp;
return 0;
}