Submission #91878

#TimeUsernameProblemLanguageResultExecution timeMemory
91878tjrwodnjs999정전 (OJUZ10_blackout)C++11
100 / 100
54 ms6776 KiB
#include <bits/stdc++.h> #define x first #define y second using namespace std; long long n,m,s,sum,l,cnt; pair<long long,long long> arr[300005]; int main() { scanf("%lld%lld",&n,&m); for(int i=0;i<n;i++){ scanf("%lld",&s); arr[i*2]={s-m,-1}; arr[i*2+1]={s+m,1}; } sort(arr,arr+2*n); for(int i=0;i<n*2;i++){ if(arr[i].y==-1){ if(sum==1) l=arr[i].x; sum++; } else{ if(sum==2) cnt+=arr[i].x-l; sum--; } } printf("%lld",cnt); }

Compilation message (stderr)

blackout.cpp: In function 'int main()':
blackout.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~
blackout.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&s);
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...