제출 #766389

#제출 시각아이디문제언어결과실행 시간메모리
766389ivopavPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; int k; cin >> k >> n; int isp=0; vector<pair<int,int>> lis={}; for (int i=0;i<n;i++){ char prvgdje; int prv; char drugdje; int dru; cin >> prvgdje >> prv >> drugdje >> dru; if (prvgdje==drugdje){ isp+=abs(prv-dru); } else { lis.push_back({prv,dru}); } } int poc=0; int kra=1000000001; int sre=kra/2; while (poc<sre){ int zbr1=0; int zbr2=0; for (int i=0;i<lis.size();i++){ zbr1+=abs(sre-lis[i].first)+abs(sre-lis[i].second); zbr2+=abs(sre+1-lis[i].first)+abs(sre+1-lis[i].second); } if (zbr1==zbr2){ break; } else if (zbr1<zbr2){ kra=sre; } else { poc=sre; } sre=(poc+kra)/2; } int zbr1=0; int zbr2=0; int zbr3=0; for (int i=0;i<lis.size();i++){ zbr1+=abs((sre-1)-lis[i].first)+abs((sre-1)-lis[i].second); zbr2+=abs((sre)-lis[i].first)+abs((sre)-lis[i].second); zbr3+=abs((sre+1)-lis[i].first)+abs((sre+1)-lis[i].second); } // cout << isp << " " << sre << " " << zbr1 << " " << zbr2 << " " << zbr3 << "\n"; cout << isp+min(zbr1,min(zbr2,zbr3))+lis.size() << "\n"; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i=0;i<lis.size();i++){
      |                      ~^~~~~~~~~~~
bridge.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i=0;i<lis.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...