제출 #586451

#제출 시각아이디문제언어결과실행 시간메모리
586451NeroZeinPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms488 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define FOR(i,a, b) for (int i=a; i<=(b); i++) #define F0R(i,a, b) for (int i=a; i>=(b); i--) using namespace std; int n, k, kep, pref[200005]; long long ans, slo, sup; vector<pair<int,int>> v; priority_queue<int>lo; priority_queue<int,vector<int>,greater<int>>hi; void ins (int x){ if (lo.empty()){lo.push(x);slo+=x;return;} if (x > lo.top()) hi.push(x), sup+=x; else lo.push(x), slo+=x; if (hi.size() > lo.size()){ int top = hi.top(); hi.pop(); lo.push(top); sup -= top; slo += top; } else if (lo.size() > hi.size()+1){ int top = hi.top(); lo.pop(); hi.push(top); slo -= top; sup += top; } } int32_t main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> k >> n; FOR(i,1,n){ char c1, c2; int x, y; cin >> c1 >> x >> c2 >> y; if (c1 == c2) kep += abs(x-y); else v.pb({x,y}); } n = v.size(); FOR(i,0,n-1){ ins(v[i].F); ins(v[i].S); pref[i] = sup-slo; } ans = pref[n-1]; if (k == 2){ while (hi.size())hi.pop(); sup=0; while (lo.size())lo.pop(); slo=0; F0R(i,n-1, 1){ ins(v[i].F); ins(v[i].S); ans = min(ans, (long long)sup-slo+pref[i-1]); } } cout << ans + kep + n; }

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

bridge.cpp: In function 'int32_t main()':
bridge.cpp:72:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   72 |         while (hi.size())hi.pop(); sup=0;
      |         ^~~~~
bridge.cpp:72:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   72 |         while (hi.size())hi.pop(); sup=0;
      |                                    ^~~
bridge.cpp:73:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   73 |         while (lo.size())lo.pop(); slo=0;
      |         ^~~~~
bridge.cpp:73:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   73 |         while (lo.size())lo.pop(); slo=0;
      |                                    ^~~
#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...