# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43490 | 2018-03-16T16:33:36 Z | Fated001 | Palembang Bridges (APIO15_bridge) | C++14 | 3 ms | 696 KB |
#include<bits/stdc++.h> using namespace std; pair<long long,long long> P[5005]; long long pos[100005]; int main() { int k,n; scanf("%d %d",&k,&n); if(k==2) assert(0); long long out=0; int cnt=0,c=0; for(int i=1;i<=n;i++) { long long a,b; char s1[2],s2[2]; scanf("%s %lld %s %lld",s1,&a,s2,&b); if(s1[0]==s2[0]) out+=abs(b-a); else { pos[++cnt]=a; pos[++cnt]=b; P[++c]={a,b}; } } long long mn=LLONG_MAX; for(int i=1;i<=cnt;i++) { long long tmp=0; for(int j=1;j<=c;j++) tmp+=abs(pos[i]-P[j].first)+1+abs(pos[i]-P[j].second); mn=min(mn,tmp); } printf("%lld\n",out+mn); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 480 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 532 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 648 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 696 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |