Submission #766322

# Submission time Handle Problem Language Result Execution time Memory
766322 2023-06-25T13:42:35 Z Gabi88 Jakarta Skyscrapers (APIO15_skyscraper) C++14
10 / 100
169 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;

int n, m, zg[2009], sk[2009], tmp, v[2009][2009];

int reks(int pos, int sum){
	if (v[0][pos] == -1 or v[0][pos] > sum) v[0][pos] = sum;
	else if (v[0][pos] < sum) return sum + 60000009;
	if (pos == 1) return sum;
	int mini = 60000009;
	for(int i=0; i<m; i++){
		if (abs(zg[i] - zg[pos]) % sk[pos] == 0 and i != pos){
			if (v[pos][i] == -1) v[pos][i] = abs(zg[i] - zg[pos]) / sk[pos];
			if (v[0][i] == -1 or v[0][i] > v[0][pos] + v[pos][i]) v[0][i] = v[0][pos] + v[pos][i];
			mini = min(reks(i, sum + v[pos][i]), mini);
		}
	}
	return mini;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; memset(v, -1, sizeof v);
	for(int i=0; i<m; i++){ cin >> zg[i] >> sk[i]; }
	tmp = reks(0, 0);
	if (tmp > n*n) cout << -1;
	else cout << tmp;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 16084 KB Output is correct
2 Correct 6 ms 16084 KB Output is correct
3 Correct 6 ms 16084 KB Output is correct
4 Correct 6 ms 16084 KB Output is correct
5 Correct 6 ms 16084 KB Output is correct
6 Correct 6 ms 16076 KB Output is correct
7 Correct 7 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 16084 KB Output is correct
2 Correct 6 ms 16084 KB Output is correct
3 Correct 6 ms 16084 KB Output is correct
4 Correct 6 ms 16084 KB Output is correct
5 Correct 6 ms 16084 KB Output is correct
6 Correct 6 ms 16084 KB Output is correct
7 Correct 8 ms 16108 KB Output is correct
8 Runtime error 169 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 16084 KB Output is correct
2 Correct 6 ms 16084 KB Output is correct
3 Correct 6 ms 16084 KB Output is correct
4 Correct 6 ms 16084 KB Output is correct
5 Correct 6 ms 16084 KB Output is correct
6 Correct 6 ms 16104 KB Output is correct
7 Correct 6 ms 16084 KB Output is correct
8 Runtime error 162 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 16056 KB Output is correct
2 Correct 8 ms 16012 KB Output is correct
3 Correct 6 ms 16084 KB Output is correct
4 Correct 7 ms 16128 KB Output is correct
5 Correct 6 ms 16076 KB Output is correct
6 Correct 6 ms 16084 KB Output is correct
7 Correct 6 ms 16080 KB Output is correct
8 Runtime error 165 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 16084 KB Output is correct
2 Correct 6 ms 16084 KB Output is correct
3 Correct 6 ms 16084 KB Output is correct
4 Correct 5 ms 16084 KB Output is correct
5 Correct 6 ms 16084 KB Output is correct
6 Correct 6 ms 16084 KB Output is correct
7 Correct 7 ms 16008 KB Output is correct
8 Runtime error 158 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -