제출 #972948

#제출 시각아이디문제언어결과실행 시간메모리
972948sleepntsheep다리 (APIO19_bridges)C11
0 / 100
34 ms1672 KiB
#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], 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; } } qsort(c+1, p, sizeof*c, cmpr); if(k==1) { for(int j=1;j<=p;++j) cost += abs(c[(p)/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) { } }

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

bridges.c: In function 'main':
bridges.c:14:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d%d", &k, &n);
      |     ^~~~~~~~~~~~~~~~~~~~~
bridges.c:18:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf(" %c%d %c%d",&bb,&s,&cc,&t);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...