답안 #936510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936510 2024-03-02T03:14:46 Z tamir1 Jakarta Skyscrapers (APIO15_skyscraper) C++14
22 / 100
11 ms 1368 KB
#include<bits/stdc++.h>
#define ll int
#define ff first
#define ss second
using namespace std;
ll n,m,i,j,b,p,x,y,R;
vector<ll> v[30005];
map<ll,ll> mp;
set<pair<ll,ll>> q;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> b >> p;
		v[b].push_back(p);
		if(i==0) q.insert({0,b});
		if(i==1) R=b;
	}
	vector<ll> dist(n,1e9);
	dist[0]=0;
	while(!q.empty()){
		pair<ll,ll> z=*q.begin();
		x=z.ss;
		y=z.ff;
		q.erase(q.begin());
		for(ll i:v[x]){
			p=0;
			for(b=x+i;b<n;b+=i){
				p++;
				if(dist[b]>y+p){
					if(dist[b]<1e9) q.erase({dist[b],b});
					dist[b]=y+p;
					q.insert({y+p,b});
				}
			}
			p=0;
			for(b=x-i;b>=0;b-=i){
				p++;
				if(dist[b]>y+p){
					if(dist[b]<1e9) q.erase({dist[b],b});
					dist[b]=y+p;
					q.insert({y+p,b});
				}
			}
		}
	}
	if(dist[R]!=1e9) cout << dist[R];
	else cout << -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1368 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 956 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1112 KB Output is correct
12 Correct 1 ms 1112 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1112 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1128 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 11 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 2 ms 1116 KB Output is correct
26 Correct 10 ms 1116 KB Output is correct
27 Correct 10 ms 1116 KB Output is correct
28 Incorrect 1 ms 1116 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1268 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 11 ms 1324 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 11 ms 1116 KB Output is correct
27 Correct 9 ms 1232 KB Output is correct
28 Incorrect 1 ms 1116 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 1 ms 1112 KB Output is correct
4 Correct 1 ms 1112 KB Output is correct
5 Correct 1 ms 1112 KB Output is correct
6 Correct 1 ms 1368 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1092 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 11 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1112 KB Output is correct
23 Correct 1 ms 1368 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 10 ms 1168 KB Output is correct
27 Correct 9 ms 1116 KB Output is correct
28 Incorrect 1 ms 1364 KB Output isn't correct
29 Halted 0 ms 0 KB -