Submission #46745

#TimeUsernameProblemLanguageResultExecution timeMemory
46745dqhungdlPalembang Bridges (APIO15_bridge)C++17
0 / 100
3 ms772 KiB
#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; }

Compilation message (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 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...