제출 #671686

#제출 시각아이디문제언어결과실행 시간메모리
671686Dan4LifePalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms388 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back using pii = pair<int,int>; #define all(a) a.begin(),a.end() #define sz(a) (int)a.size() const int maxn = (int)1e5+10; const int LINF = (int)1e18; vector<int> v; vector<pii> seg; set<pii> bef,dur,aft; int t, n, sum_bef, sum_dur, sum_aft, tot, ans=LINF; int a[maxn], b[maxn]; int chk(int a[]){ priority_queue<int> p1; while(!p1.empty())p1.pop(); priority_queue<int,vector<int>,greater<int>> p2; while(!p1.empty())p1.pop(); while(!p2.empty())p2.pop(); int sum = 0, x; for(int i = 0; i < sz(seg); i++){ p1.push(seg[i].se), p1.push(seg[i].fi-seg[i].se); sum-=seg[i].se, sum-=seg[i].fi-seg[i].se; while(!p1.empty() and sz(p1)>sz(p2)) x=p1.top(), p1.pop(),p2.push(x), sum+=2*x; while(!p2.empty() and sz(p1)<sz(p2)) x=p2.top(), p2.pop(),p1.push(x), sum-=2*x; a[i]=sum; } return sum; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> t >> n; int ans = LINF; for(int i = 0; i < n; i++){ char a, c; int b, d; cin >> a >> b >> c >> d; if(a==c) tot+=abs(b-d); else seg.pb({b+d, min(b,d)}), tot++, v.pb(b), v.pb(d); } sort(all(v)); sort(all(seg)); if(!seg.empty()) ans = chk(a); if(t==2){ chk(a),reverse(all(seg)),chk(b); for(int i = 0; i < sz(seg); i++) ans = min(ans, a[i]+b[sz(seg)-i-1]); } if(seg.empty()) ans=0; cout << ans+tot; }

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

bridge.cpp: In function 'long long int chk(long long int*)':
bridge.cpp:22:2: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   22 |  while(!p1.empty())p1.pop(); while(!p2.empty())p2.pop();
      |  ^~~~~
bridge.cpp:22:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   22 |  while(!p1.empty())p1.pop(); while(!p2.empty())p2.pop();
      |                              ^~~~~
#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...