Submission #124200

#TimeUsernameProblemLanguageResultExecution timeMemory
124200elabensaadJakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
3 ms1084 KiB
#include <bits/stdc++.h> using namespace std; int n, m, x, y, vis[30005], p[30005]; vector <pair <int , int> > t[30005]; void DJ(int u){ priority_queue <pair <int, int> >q; vis[u] = 1; q.push({-1, u}); while(!q.empty()){ int l = q.top().second; q.pop(); for(int i = 0;i < t[l].size();i++){ int nc = vis[l]+t[l][i].second; if(vis[t[l][i].first] == 0 || nc < vis[t[l][i].first]){ vis[t[l][i].first] = nc; q.push({-nc, t[l][i].first}); } } } } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 0;i < m;i++){ cin >> x >> p[i]; int k = x; t[i].push_back({x, 0}); int cur = 0; while(x+p[i] < n){ x+=p[i]; cur++; t[i].push_back({x, cur}); } cur = 0; while(k-p[i] > 0){ k-=p[i]; cur++; t[i].push_back({k, cur}); } } DJ(0); if(vis[1] == 0)cout << -1; else cout << vis[1] ; }

Compilation message (stderr)

skyscraper.cpp: In function 'void DJ(int)':
skyscraper.cpp:15:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i < t[l].size();i++){
                       ~~^~~~~~~~~~~~~
#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...