# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972944 | 2024-05-01T10:36:29 Z | sleepntsheep | Bridges (APIO19_bridges) | C | 41 ms | 1500 KB |
#include <stdio.h> #include <stdlib.h> #define MAX_N 2000000 int min(int a,int b){return a<b?a:b;} int max(int a,int b){return a>b?a:b;} int cmpr(const void*a,const void*b){return *(const int*)a - *(const int*)b;} int n, k, c[MAX_N<<1], o, p; long long cost; int main() { scanf("%d%d", &k, &n); for (int s, t, i = 0; i < n; ++i) { char bb, cc; scanf(" %c%d %c%d",&bb,&s,&cc,&t); if(bb==cc) cost += abs(t-s); else { c[++p] = s; c[++p] = t; ++cost; ++o; } } qsort(c+1, p-1, sizeof*c, cmpr); if(k==1) { for(int j=1;j<=p;++j) cost += abs(c[(p+1)/2] - c[j]); printf("%lld\n", cost); return 0; } /* some prefix of points will choose left bridge and the rest will choose right bridge * * - fix prefix and find optimal cost for that prefix */ for (int i = 0; i < p; ++i) { } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 860 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 860 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 41 ms | 1500 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 860 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |