이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
int k,n;ll re=0;
map<ll,int>st,en;
ll no=0,fin=0;vector<ll>v;
int main()
{
cin>>k>>n;ll w=0;
for(int i=0;i<n;i++)
{
char a,b;
int x,y;
cin>>a>>x>>b>>y;
re+=abs(x-y);
if(a==b)continue;
re-=(abs(x-y));
re++;
if(x>y)swap(x,y);
v.pb(x);v.pb(y);
st[x]++;
st[y];no++;
en[y]++;w+=x;
}
ll mn=1e18;
ll last=0;
sort(v.begin(),v.end());
ll r=0;
for(int i=0;i<v.size();i++)
{
r+=abs(v[i]-v[v.size()/2]);
}
for(int j=0;j<v.size();j++)
{
ll z=0;
for(int i=0;i<v.size();i++)
{
z+=abs(v[i]-v[j]);
}
mn=min(mn,z);
z=0;
/*
w+=fin*(it.fi-last);
w-=no*(it.fi-last);
fin+=en[it.fi];
no-=st[it.fi];
mn=min(mn,w);last=it.fi;
*/
}
re+=r;
if(r<mn)
{
while(1)w++;
}
cout<<re;
}
컴파일 시 표준 에러 (stderr) 메시지
bridge.cpp: In function 'int main()':
bridge.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
bridge.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int j=0;j<v.size();j++)
| ~^~~~~~~~~
bridge.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
bridge.cpp:29:8: warning: unused variable 'last' [-Wunused-variable]
29 | ll last=0;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |