제출 #549877

#제출 시각아이디문제언어결과실행 시간메모리
549877ala2Palembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms300 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define F first #define S second #define B begin() #define E end() using namespace std; vector<pair<int,int>>v; int f(int x) { int g=0; for(int i=0;i<v.size();i++) { g+=abs(v[i].F-x )+abs(v[i].S-x); } return g; } signed main() { int n,k; cin>>k>>n; int ans=0; for(int i=0;i<n;i++) { char x,y; int a,b; cin>>x>>a>>y>>b; if(x==y) { ans+=abs(a-b); } else v.pb({a,b}),ans++; } int mn=1e18; for(int i=0;i<v.size();i++) { mn=min(mn,f(v[i].F)); } cout<<mn+ans<<endl; }

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

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