| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 170569 | Swan | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 79 ms | 1400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define stop system("pause")
#define stop2 char o; cin >> o
#define INP freopen("pcb.in","r",stdin)
#define OUTP freopen ("pcb.out","w",stdout)
using namespace std;
const int maxn = 210;
int ans[2001];
vector<int> qwe[2001];
vector<pair<int,int> > v;
priority_queue<pair<int,int> > q;
int n,m;
void solve(int start){
ans[start] = 0;
q.push({0,start});
while(q.size()){
//stop;
int now = q.top().second;
int dist = -q.top().first;
//cerr << now << endl;
q.pop();
if(dist > ans[now])continue;
//cout << now << ' ' << ans[now] << endl;
for(int i(0); i < qwe[now].size();i++){
int w = qwe[now][i];
int p = qwe[now][i];
int cnt = 1;
while(now+p < n){
if(ans[now+p] > ans[now]+cnt){
ans[now+p] = ans[now]+cnt;
q.push({-ans[now+p],now+p});
}
cnt++;
p+=w;
}
p = -w;
cnt = 1;
while(now+p >= 0){
if(ans[now+p] > ans[now]+cnt){
ans[now+p] = ans[now]+cnt;
q.push({-ans[now+p],now+p});
}
cnt++;
p-=w;
}
}
}
}
main(){
ios_base::sync_with_stdio(0);
cin >> n >> m;
for(int i(0);i<=n;i++)ans[i] = 1e9;
int need;
for(int i(0); i < m;i++){
int b,p; cin >> b >> p;
v.push_back({b,p});
qwe[b].push_back(p);
if(i==1)need = b;
}
solve(v[0].first);
if(ans[need] == 1e9)cout << -1;
else cout << ans[need];
}
/*
5 3
0 2
1 1
4 1
*/
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
