이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int64_t,int64_t> ii;
typedef pair<int64_t,ii> iii;
int64_t T,n,res=0;
vector<int> V1,V2;
vector<iii> V;
int main()
{
ios_base::sync_with_stdio(false);
//freopen("TEST.INP","r",stdin);
cin>>T>>n;
char c1,c2;
int64_t t1,t2;
while(n--)
{
cin>>c1>>t1>>c2>>t2;
if(c1==c2)
res+=abs(t1-t2);
else
{
res++;
V.push_back(iii(t1+t2,ii(t1,t2)));
}
}
sort(V.begin(),V.end());
for(int64_t i=0;i<V.size()/2;i++)
{
V1.push_back(V[i].second.first);
V1.push_back(V[i].second.second);
}
for(int64_t i=V.size()/2;i<V.size();i++)
{
V2.push_back(V[i].second.first);
V2.push_back(V[i].second.second);
}
sort(V1.begin(),V1.end());
sort(V2.begin(),V2.end());
for(int64_t i=0;i<V1.size();i++)
res+=abs(V1[i]-V1[V1.size()/2-1]);
for(int64_t i=0;i<V2.size();i++)
res+=abs(V2[i]-V2[V2.size()/2-1]);
cout<<res;
}
컴파일 시 표준 에러 (stderr) 메시지
bridge.cpp: In function 'int main()':
bridge.cpp:29:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int64_t i=0;i<V.size()/2;i++)
~^~~~~~~~~~~
bridge.cpp:34:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int64_t i=V.size()/2;i<V.size();i++)
~^~~~~~~~~
bridge.cpp:41:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int64_t i=0;i<V1.size();i++)
~^~~~~~~~~~
bridge.cpp:43:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int64_t i=0;i<V2.size();i++)
~^~~~~~~~~~
# | 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... |