Submission #1028713

# Submission time Handle Problem Language Result Execution time Memory
1028713 2024-07-20T07:29:30 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
10 / 100
1000 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	int b[m],p[m],dp[m];
	for (int i=0;i<m;i++)
		cin>>b[i]>>p[i],dp[i]=1e9;
	dp[1]=0;
	for (int ct=0;ct<m;ct++)
	{
		int dp1[m];
		for (int i=0;i<m;i++)
		{
			dp1[i]=dp[i];
			for (int j=0;j<m;j++)
			{
				if ((b[i]-b[j])%p[i]==0)
					dp1[i]=min(dp1[i],dp[j]+abs(b[i]-b[j])/p[i]);
			}
		}
		for (int i=0;i<m;i++)
			dp[i]=dp1[i];
	}
	if (dp[0]==1e9)
		dp[0]=-1;
	cout<<dp[0]<<endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 148 ms 412 KB Output is correct
11 Execution timed out 1069 ms 344 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 143 ms 412 KB Output is correct
11 Execution timed out 1066 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 146 ms 404 KB Output is correct
11 Execution timed out 1008 ms 344 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 148 ms 408 KB Output is correct
11 Execution timed out 1031 ms 344 KB Time limit exceeded
12 Halted 0 ms 0 KB -