## 답안 #105988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105988 2019-04-16T04:29:33 Z Hideo Jakarta Skyscrapers (APIO15_skyscraper) C++14
0 / 100
8 ms 5120 KB
```#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pii pair < int, pi >
#define vii vector < pi >

const int N = 2e5 + 7;
const int INF = 1e9 + 7;

int l[N], p[N], us[N];
int n, m, ans;

vii g[N];

void dfs (int v = 1, int c = 0){
if (c >= us[v])
return;
us[v] = c;
if (v == 2){
ans = min(ans, c);
return;
}
for (pi to : g[v])
dfs(to.fr, c + to.sc);
}

main(){
ans = INF;
cin >> n >> m;
for (int i = 1; i <= m; i++){
us[i] = INF;
scanf("%d%d", &l[i], &p[i]);
}
for (int i = 1; i <= m; i++)
for (int j = 1; j <= m; j++)
if (i != j && l[i] % p[i] == l[j] % p[i])
g[i].pb(mk(j, abs(l[j] - l[i]) / p[i]));
dfs();
cout << ans;
}
```

### Compilation message

```skyscraper.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &l[i], &p[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~```

#### Subtask #1 0 / 10.0

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 6 ms 4992 KB Output is correct
3 Correct 6 ms 4992 KB Output is correct
4 Incorrect 6 ms 4992 KB Output isn't correct
5 Halted 0 ms 0 KB -

#### Subtask #2 0 / 12.0

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 6 ms 4992 KB Output is correct
3 Correct 7 ms 4992 KB Output is correct
4 Incorrect 7 ms 4992 KB Output isn't correct
5 Halted 0 ms 0 KB -

#### Subtask #3 0 / 14.0

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 6 ms 5120 KB Output is correct
3 Correct 6 ms 4992 KB Output is correct
4 Incorrect 8 ms 4964 KB Output isn't correct
5 Halted 0 ms 0 KB -

#### Subtask #4 0 / 21.0

# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5040 KB Output is correct
2 Correct 6 ms 4992 KB Output is correct
3 Correct 6 ms 4992 KB Output is correct
4 Incorrect 6 ms 4992 KB Output isn't correct
5 Halted 0 ms 0 KB -

#### Subtask #5 0 / 43.0

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 8 ms 4992 KB Output is correct
3 Correct 6 ms 4992 KB Output is correct
4 Incorrect 6 ms 4992 KB Output isn't correct
5 Halted 0 ms 0 KB -