제출 #932785

#제출 시각아이디문제언어결과실행 시간메모리
932785Yazan_AlattarAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
726 ms118336 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 1000007; const ll inf = 1e9; const ll INF = 1e12; const ll mod = 1e9 + 7; const double eps = 1e-6; vector < pair <ll,ll> > order; vector <int> adj[M]; map <ll,ll> mp; ll n, a[M], b[M], dist[M]; bool reached[M]; void AddEdges(){ for(int i = 1; i < order.size(); ++i){ int l = order[i - 1].S; int r = order[i].S; adj[l].pb(r); adj[r].pb(l); } return; } void Dijkstra(){ priority_queue < pair <ll,ll> > q; for(int i = 1; i <= n; ++i){ q.push({b[i], i}); dist[i] = b[i]; } while(!q.empty()){ int node = q.top().S; ll cost = q.top().F; q.pop(); if(dist[node] > cost) continue; for(auto i : adj[node]){ ll d = abs(a[i] - a[node]); if(dist[node] - d >= b[i]) reached[i] = 1; if(dist[node] - d > dist[i]){ dist[i] = dist[node] - d; q.push({dist[i], i}); } } } return; } void solve(int _){ cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i] >> b[i]; mp[a[i]] = max(mp[a[i]], b[i]); } int idx = 0; for(auto i : mp){ ++idx; a[idx] = i.F; b[idx] = i.S; } n = idx; for(int i = 1; i <= n; ++i) order.pb({a[i], i}); sort(all(order)); AddEdges(); Dijkstra(); ll ans = n; for(int i = 1; i <= n; ++i) if(reached[i]) --ans; cout << ans << endl; return; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; for(int i = 1; i <= t; ++i) solve(t); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void AddEdges()':
Main.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 1; i < order.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...