제출 #422167

#제출 시각아이디문제언어결과실행 시간메모리
422167MDario전선 연결 (IOI17_wiring)C++11
17 / 100
1087 ms10256 KiB
#include "wiring.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second ll a[200001]; vector<pair<ll, bool>> v; ll f(ll af, ll bf, ll df){ if(bf-af+1>df-bf){ return (a[df]-a[bf])-(a[bf]-a[af-1])+((bf-af+1)-(df-bf))*v[bf+1].F; } else{ return (a[df]-a[bf])-(a[bf]-a[af-1])-((df-bf)-(bf-af+1))*v[bf].F; } } long long min_total_length(vector<int> r, vector<int> b) { ll n=r.size(), m=b.size(), c[20]; for(int i=0; i<n; i++)v.push_back({r[i], 0}); for(int i=0; i<m; i++)v.push_back({b[i], 1}); if(r[0]<b[0]) v.push_back({-1, 1}); else v.push_back({-1, 0}); sort(v.begin(), v.end()); ll dp[v.size()]; c[0]=-1; c[1]=-1; dp[0]=0; a[0]=0; for(int i=1; i<v.size(); i++){ a[i]=v[i].F+a[i-1]; } for(int i=1; i<v.size(); i++){ dp[i]=100000000000000000ll; if(v[i].S==0){ if(c[1]!=-1){ dp[i]=f(c[1], c[1], i)+dp[c[1]]; for(int t=c[1]; v[t].S==1; t--)dp[i]=min(dp[i], f(t, c[1], i)+dp[t-1]); } c[0]=i; } else{ if(c[0]!=-1){ dp[i]=f(c[0], c[0], i)+dp[c[0]]; for(int t=c[0]; v[t].S==0; t--)dp[i]=min(dp[i], f(t, c[0], i)+dp[t-1]); } c[1]=i; } //cout << dp[i] << " "; } return dp[n+m]; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=1; i<v.size(); i++){
      |                  ~^~~~~~~~~
wiring.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=1; i<v.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...