답안 #1023973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023973 2024-07-15T10:19:14 Z Muhammet Jakarta Skyscrapers (APIO15_skyscraper) C++17
0 / 100
1 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

#define N 30005
#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second

ll T, n, m, b[N], p[N], d[N], vis[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n >> m;

	for(int i = 0; i < m; i++){
		cin >> b[i] >> p[i];
		d[i] = 1e9;
	}
	d[0] = 0;
	int x = 0;
	vis[0] = 1;
	while(1){
		ll mn = 1e9, ind = x;
		for(int i = 0; i < m; i++){
			if(vis[i] == 1) continue;
			int k = (abs(b[i]-b[x]));
			if(d[i] < mn) ind = i;
			mn = min(d[i],mn);
			if(k % p[x] != 0) continue;
			d[i] = min(d[x] + (k/p[x]), d[i]);
			if(d[i] < mn) ind = i;
			mn = min(d[i],mn);
		}
		if(x == ind) break;
		x = ind;
		vis[x] = 1;
	}

	cout << d[1];

	return 0;
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -