Submission #1116174

# Submission time Handle Problem Language Result Execution time Memory
1116174 2024-11-21T09:58:56 Z staszic_ojuz Semiexpress (JOI17_semiexpress) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int ilosc_stacji,ilosc_express,ilosc_semi;
	int czas_local,czas_express,czas_semi;
	int maks_czas,gdzie_pociag_exp;
	cin >> ilosc_stacji >> ilosc_express >> ilosc_semi;
	cin >> czas_local >> czas_express >> czas_semi;
	cin >> maks_czas;
	vector<int>pozycje_exp;
	for(int i=0;i<ilosc_express;++i){
		cin >> gdzie_pociag_exp;
		pozycje_exp.push_back(gdzie_pociag_exp);
	}
	vector<int>dp(ilosc_stacji);
	vector<bool>semi(ilosc_stacji);
	semi[0]=1;
	for(int i=1;i<ilosc_express;++i){
		dp[pozycje_exp[i]-1]=dp[pozycje_exp[i-1]-1]+(pozycje_exp[i]-pozycje_exp[i-1])*czas_express;
		semi[pozycje_exp[i]-1]=1;
	}
	for(int i=1;i<ilosc_stacji;++i){
		if(dp[i]!=0)
			dp[i]=min(dp[i-1]+czas_local,dp[i]);
		else
			dp[i]=dp[i-1]+czas_local;
	}

	int index;
	for(int i=0;i<ilosc_stacji;++i){
		if(semi[i]) index=i;
		if(dp[i]>maks_czas){
			if(dp[index]+czas_semi*(i-index+1)<=maks_czas && ilosc_semi >0 ){
				dp[i]=dp[index]+czas_semi*(i-index+1);
				semi[i]=1;
				index=i;
				ilosc_semi--;
			}
		}
	}
	int suma=0;
	for(int i=0;i<ilosc_stacji;++i){
		if(dp[i]>maks_czas)
			suma++;
	}
	cout << ilosc_stacji-suma-1;
	return 0;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:35:15: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |    if(dp[index]+czas_semi*(i-index+1)<=maks_czas && ilosc_semi >0 ){
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -