# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17347 | 2015-11-23T02:05:32 Z | comet | Palembang Bridges (APIO15_bridge) | C++ | 0 ms | 4240 KB |
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; int K,N; ll base; ll a[200010],sum[200010],sz; int main(){ scanf("%d%d ",&K,&N); char tx,ty; ll x,y; for(int i=0;i<N;i++){ scanf("%c %lld %c %lld ",&tx,&x,&ty,&y); if(tx==ty){ base+=abs(x-y); }else{ a[++sz]=x; a[++sz]=y; base++; } } sort(a+1,a+sz+1); a[sz+1]=-1; for(int i=1;i<=sz;i++){ sum[i]=sum[i-1]+a[i]; } ll ans=1e18; for(ll i=1;i<=sz;i++){ x=a[i]; ans=min(ans,sum[sz]-2ll*sum[i]+(2ll*i-sz)*x); } printf("%lld\n",ans+base); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |