제출 #582833

#제출 시각아이디문제언어결과실행 시간메모리
582833Justin1Palembang Bridges (APIO15_bridge)C++14
22 / 100
117 ms6924 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; struct ppl { ll h,o; //house, office bool operator < (const ppl & x) const { return h+o < x.h+x.o; } }; ll n,m,k,x,y,z; char st, ed; ll cal(vector<ppl> & city, vector<ll> & median) { ll ans = 0; if (median.size()) { sort(median.begin(),median.end()); ll bridge = median[median.size()/2]; for (auto i : city) ans += abs(i.h-bridge) + abs(i.o-bridge) + 1; } return ans; } signed main() { cin >> m >> n; vector<ll> median; vector<ppl> city; ll ans = 0, mn = 1e18; for (int i = 1; i <= n; i++) { cin >> st >> x >> ed >> y; if (st == ed) ans += abs(x-y); else city.push_back({x,y}); } sort(city.begin(),city.end()); for (int i = 0; i < (m == 1 ? 1 : city.size()); i++) { vector<ppl> c1, c2; vector<ll> m1, m2; for (int j = 0; j < i; j++) { c1.push_back(city[j]); m1.push_back(city[j].h); m1.push_back(city[j].o); } for (int j = i; j < city.size(); j++) { c2.push_back(city[j]); m2.push_back(city[j].h); m2.push_back(city[j].o); } mn = min(mn,cal(c1,m1)+cal(c2,m2)); } cout << ans + mn << "\n"; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
   36 |  for (int i = 0; i < (m == 1 ? 1 : city.size()); i++) {
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
bridge.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ppl>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int j = i; j < city.size(); 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...