Submission #91878

# Submission time Handle Problem Language Result Execution time Memory
91878 2018-12-30T23:45:55 Z tjrwodnjs999 정전 (OJUZ10_blackout) C++11
100 / 100
54 ms 6776 KB
#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

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 time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 4216 KB Output is correct
2 Correct 48 ms 6392 KB Output is correct
3 Correct 19 ms 2796 KB Output is correct
4 Correct 47 ms 6136 KB Output is correct
5 Correct 50 ms 6492 KB Output is correct
6 Correct 32 ms 4472 KB Output is correct
7 Correct 34 ms 4344 KB Output is correct
8 Correct 5 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4300 KB Output is correct
2 Correct 52 ms 6552 KB Output is correct
3 Correct 27 ms 3576 KB Output is correct
4 Correct 53 ms 6648 KB Output is correct
5 Correct 34 ms 4340 KB Output is correct
6 Correct 52 ms 6532 KB Output is correct
7 Correct 34 ms 4472 KB Output is correct
8 Correct 35 ms 4600 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 53 ms 6776 KB Output is correct
11 Correct 54 ms 6492 KB Output is correct
12 Correct 52 ms 6520 KB Output is correct
13 Correct 52 ms 6520 KB Output is correct
14 Correct 34 ms 4472 KB Output is correct
15 Correct 21 ms 2752 KB Output is correct