Submission #70591

#TimeUsernameProblemLanguageResultExecution timeMemory
70591KmcodeWiring (IOI17_wiring)C++14
13 / 100
55 ms5700 KiB
#include <bits/stdc++.h> using namespace std; #include "wiring.h" long long int dp[202]; vector<pair<int,int> > v; long long min_total_length(std::vector<int> r, std::vector<int> b) { v.clear(); for(int i=0;i<r.size();i++){ v.push_back(make_pair(r[i],0)); //red } for(int i=0;i<b.size();i++){ v.push_back(make_pair(b[i],1)); //blue } sort(v.begin(),v.end()); vector<int> stk[2]; vector<int> al[2]; long long int dist=0; for(int i=0;i<v.size();i++){ int ty=v[i].second; int op=(ty^1); if(stk[op].size()){ dist+=v[i].first-stk[op].back(); stk[op].pop_back(); } else{ stk[ty].push_back(v[i].first); } al[ty].push_back(v[i].first); } for(int i=0;i<2;i++){ for(int j=0;j<stk[i].size();j++){ long long int el=stk[i][j]; int id=lower_bound(al[i^1].begin(),al[i^1].end(),el)-al[i^1].begin(); long long int f=LLONG_MAX; if(al[i^1].size()!=id){ f=min(f,al[i^1][id]-el); } if(id){ f=min(f,el-al[i^1][id-1]); } dist+=f; } } return dist; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++){
              ~^~~~~~~~~
wiring.cpp:17:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<b.size();i++){
              ~^~~~~~~~~
wiring.cpp:24:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
              ~^~~~~~~~~
wiring.cpp:37:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<stk[i].size();j++){
               ~^~~~~~~~~~~~~~
wiring.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(al[i^1].size()!=id){
       ~~~~~~~~~~~~~~^~~~
#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...