Submission #14459

#TimeUsernameProblemLanguageResultExecution timeMemory
14459yys980정전 (OJUZ10_blackout)C++98
100 / 100
48 ms5772 KiB
#include <stdio.h> #include <algorithm> using namespace std; int n,l; long long sum; long long slight[300000],elight[300000]; int main() { scanf("%d %d",&n, &l); int i; for(i = 1 ; i <= n ; i++){ scanf("%lld",&slight[i]); slight[i]-=l; } sort(slight+1,slight+1+n); for(i = 1 ; i <= n ; i++){ elight[i]=slight[i]+l*2; } int s=slight[1],x=elight[1]; for(i = 2 ; i <= n ; i++){ if(s<slight[i])s=slight[i]; if(s<=x){ sum+=x-s; s=x; } x=elight[i]; } printf("%lld",sum); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...