제출 #792609

#제출 시각아이디문제언어결과실행 시간메모리
792609Kaitokid전선 연결 (IOI17_wiring)C++17
0 / 100
1 ms296 KiB
//#include "wiring.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll min_total_length(vector<int> r, vector<int> b) { int n=r.size()+b.size(); vector<pair<ll,ll> > g; g.push_back({-1,-1}); for(int i=0;i<r.size();i++)g.push_back({r[i],0}); for(int i=0;i<b.size();i++)g.push_back({b[i],1}); sort(g.begin(),g.end()); vector<ll>dp(n+1),pr(n+1),lst(3*n,-1); vector<ll>prv={-1,-1}; ll s=0; lst[n]=0; for(int i=1;i<=n;i++) { pr[i]=pr[i-1]+(2*g[i].second-1)*g[i].first; s+=2*g[i].second-1; prv[g[i].second]=i; if(prv[1-g[i].second]!=-1) { dp[i]=dp[i-1]+g[i].first-g[prv[1-g[i].second]].first; if(lst[n+s]!=-1) { dp[i]=min(dp[i],dp[lst[n+s]]+abs(pr[i]-pr[lst[s+n]])); } } else dp[i]=10000000000000000; lst[n+s]=i; } return dp[n]; } /*int main() { cout<<min_total_length({1, 2, 3, 7}, {0, 4, 5, 9, 10}); } */

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

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | for(int i=0;i<r.size();i++)g.push_back({r[i],0});
      |             ~^~~~~~~~~
wiring.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | for(int i=0;i<b.size();i++)g.push_back({b[i],1});
      |             ~^~~~~~~~~
#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...