Submission #14167

#TimeUsernameProblemLanguageResultExecution timeMemory
14167pichulia정전 (OJUZ10_blackout)C++98
100 / 100
51 ms8896 KiB
#include<stdio.h> #include<algorithm> using namespace std; long long int n, m; long long int a[1000000]; long long int res; int main() { int i, j, k, l; scanf("%lld %lld",&n,&m); for(i=0;i<n;i++){scanf("%lld",&a[i]);a[i]-=m;} sort(a,a+n); m=2*m; long long int si=a[0]; long long int ei=a[0]+m; for(i=1;i<n;i++) { // printf("%d %d %d\n",si,ei,a[i]); if(si<a[i])si=a[i]; if(ei>si){res += ei-si; si=ei;} ei=a[i]+m; } printf("%lld\n",res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...