제출 #68775

#제출 시각아이디문제언어결과실행 시간메모리
68775Inovak전선 연결 (IOI17_wiring)C++14
42 / 100
127 ms16136 KiB
//#include "grader.cpp" #include "wiring.h" #include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define ll long long #define OK puts("OK"); #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() using namespace std; const int N = 5e5+10; const int nn = 2e5; const ll inf = 1e16+7; ll n, m, x, b; ll dp[N], sum[N]; ll pr[N]; vector <pair <ll, ll> > all; ll get(int l, int r) { return abs(sum[r] - sum[l - 1]); } long long min_total_length(vector<int> R, vector<int> B) { n = sz(R); m = sz(B); for(int i = 0; i < n; i++) { all.pb(mk(R[i], 1)); dp[i+1] = inf; } for(int i = 0; i < m; i++) { all.pb(mk(B[i], 0)); dp[i + n + 1] = inf; } if(R.back() < B[0]) { ll ans = 0; for(int i = 0; i < sz(R) - 1; i++) ans += R.back() - R[i]; for(int i = 1; i < sz(B); i++) ans += B[i] - B[0]; return ans + max(sz(R), sz(B)) * (B[0] - R.back()); } R.insert(R.begin(), -inf); R.insert(R.end(), inf); B.insert(B.begin(), -inf); B.insert(B.end(), inf); n += m; all.pb(mk(-inf, -1)); sort(all(all)); memset(pr, -1, sizeof(pr)); pr[nn] = 0; for(int i = 1; i <= n; i++) { sum[i] = sum[i - 1] + (all[i].sc ? -all[i].fr : all[i].fr); b += (all[i].sc ? -1 : 1); int j = pr[b + nn]; pr[b + nn] = i; ll nl, nr; if (all[i].sc) { nl = *(lower_bound(B.begin(), B.end(), all[i].first) - 1); nr = *lower_bound(B.begin(), B.end(), all[i].first); } else { nl = *(lower_bound(R.begin(), R.end(), all[i].first) - 1); nr = *lower_bound(R.begin(), R.end(), all[i].first); } dp[i] = dp[i - 1] + min(all[i].first - nl, nr - all[i].first); if(j == -1) continue; dp[i] = min(dp[i], dp[j] + get(j + 1, i)); } return dp[n]; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:50:25: warning: overflow in implicit constant conversion [-Woverflow]
     R.insert(R.begin(), -inf);
                         ^~~~
wiring.cpp:51:26: warning: overflow in implicit constant conversion [-Woverflow]
     R.insert(R.end(), inf);
                          ^
wiring.cpp:52:25: warning: overflow in implicit constant conversion [-Woverflow]
     B.insert(B.begin(), -inf);
                         ^~~~
wiring.cpp:53:26: warning: overflow in implicit constant conversion [-Woverflow]
     B.insert(B.end(), inf);
                          ^
#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...