Submission #977499

#TimeUsernameProblemLanguageResultExecution timeMemory
977499AmaarsaaJakarta Skyscrapers (APIO15_skyscraper)C++14
36 / 100
1094 ms2192 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; ll D[30005]; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans, s, sum, x, y, r, p, i, j; cin >> m >> n; priority_queue < pair < ll, ll >, vector < pair < ll, ll >> , greater < pair < ll, ll >> > pq; ll a[n + 2], b[n + 2]; for (i = 0; i < n; i ++) { cin >> a[i] >> b[i]; D[i] = 1e18; } D[0] = 0; pq.push({0, 0}); while(!pq.empty()) { x = pq.top().first; i = pq.top().second; pq.pop(); if ( x != D[i]) continue; if ( i == 1) { cout << x << endl; return 0; } for (j = 0; j < n; j ++) { if ( (abs(a[j] - a[i])) % b[i] == 0) { s = abs(a[j] - a[i]) / b[i]; if (D[j] > D[i] + s) { D[j] = D[i] + s; pq.push({D[j], j}); } } } } cout << -1 << endl; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:11:5: warning: unused variable 't' [-Wunused-variable]
   11 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |     ^
skyscraper.cpp:11:14: warning: unused variable 'ans' [-Wunused-variable]
   11 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |              ^~~
skyscraper.cpp:11:22: warning: unused variable 'sum' [-Wunused-variable]
   11 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                      ^~~
skyscraper.cpp:11:30: warning: unused variable 'y' [-Wunused-variable]
   11 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                              ^
skyscraper.cpp:11:33: warning: unused variable 'r' [-Wunused-variable]
   11 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                                 ^
skyscraper.cpp:11:36: warning: unused variable 'p' [-Wunused-variable]
   11 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...