Submission #32179

#TimeUsernameProblemLanguageResultExecution timeMemory
32179minchurlPalembang Bridges (APIO15_bridge)C++11
22 / 100
76 ms2672 KiB
#include<stdio.h> #include<math.h> #include<algorithm> #define MAX_N 100005 #define abs(x) ((x)>0?(x):(-(x))) #define LL long long using namespace std; LL N,K; LL arr[2*MAX_N],ans; LL input(){ LL i,n,S,T,sum=0; char P[2],Q[2]; n=0; for(i=0;i<N;i++){ scanf("%s %lld %s %lld",P,&S,Q,&T); if(P[0]==Q[0]){ sum+=abs(S-T); }else{ arr[++n]=S;arr[++n]=T; sum++; } } N=n; return sum; } LL bridge_only(){ LL i,x,sum=0; sort(arr+1,arr+N+1); x=N/2; for(i=1;i<=N;i++) sum+=abs(arr[i]-arr[x]); return sum; } int main(){ LL base; scanf("%lld %lld",&K,&N); base=input(); ans=bridge_only()+base; if(K==1){ printf("%lld\n",ans); return 0; } return 0; }

Compilation message (stderr)

bridge.cpp: In function 'long long int input()':
bridge.cpp:15:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s %lld %s %lld",P,&S,Q,&T);
                                     ^
bridge.cpp: In function 'int main()':
bridge.cpp:35:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&K,&N);
                          ^
#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...