Submission #717110

#TimeUsernameProblemLanguageResultExecution timeMemory
717110myrcellaWiring (IOI17_wiring)C++17
13 / 100
26 ms3788 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} #include "wiring.h" long long min_total_length(std::vector<int> r, std::vector<int> b) { if (SZ(r)>SZ(b)) swap(r,b); int cur = 0; ll ans = 0; rep(i,0,SZ(r)) { ans += abs(b[cur++]-r[i]); while (cur<SZ(b) and SZ(b)-cur-1>=SZ(r)-1-i and (i==SZ(r)-1 or abs(b[cur]-r[i])<abs(b[cur]-r[i+1]))) { ans += abs(b[cur++]-r[i]); } } return ans; }
#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...