Submission #923280


Source Code Expand

Copy
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
#define mod 1000000007
#define INF 0x7fffffffff
#define N 300100
#define endl '\n'
int a[110000],dp[110000][25];
int main()
{
    int n,m,L;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    scanf("%d%d",&L,&m);
    for(int i=1;i<=n;i++) dp[i][0]=upper_bound(a+i+1,a+1+n,a[i]+L)-a-1;
    for(int j=0;j<18;j++)
        for(int i=1;i<=n;i++)
            dp[i][j+1]=dp[dp[i][j]][j];
    while(m--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        if(l>r) swap(l,r);
        int ans=1;
        for(int i=17;i>=0;i--)
        {
            if(dp[l][i]<r) ans+=(1<<i),l=dp[l][i];
        }
        cout<<ans<<endl;
    }
	return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User mirac1e
Language C++14 (GCC 5.4.1)
Score 700
Code Size 865 Byte
Status AC
Exec Time 84 ms
Memory 11008 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:18:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
./Main.cpp:19:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                                            ^
./Main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&L,&m);
                        ^
./Main.cpp:28:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&l,&r);
                            ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 1
AC × 14
AC × 27
Set Name Test Cases
Sample example_01.txt
Subtask1 example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt
All example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt
Case Name Status Exec Time Memory
example_01.txt AC 3 ms 256 KB
subtask1_01.txt AC 3 ms 256 KB
subtask1_02.txt AC 3 ms 256 KB
subtask1_03.txt AC 3 ms 384 KB
subtask1_04.txt AC 3 ms 384 KB
subtask1_05.txt AC 3 ms 384 KB
subtask1_06.txt AC 3 ms 256 KB
subtask1_07.txt AC 3 ms 256 KB
subtask1_08.txt AC 3 ms 384 KB
subtask1_09.txt AC 3 ms 384 KB
subtask1_10.txt AC 3 ms 384 KB
subtask1_11.txt AC 3 ms 384 KB
subtask1_12.txt AC 3 ms 384 KB
subtask1_13.txt AC 3 ms 384 KB
subtask2_01.txt AC 76 ms 10880 KB
subtask2_02.txt AC 84 ms 11008 KB
subtask2_03.txt AC 77 ms 10752 KB
subtask2_04.txt AC 41 ms 7040 KB
subtask2_05.txt AC 51 ms 7168 KB
subtask2_06.txt AC 62 ms 10624 KB
subtask2_07.txt AC 79 ms 10880 KB
subtask2_08.txt AC 84 ms 11008 KB
subtask2_09.txt AC 84 ms 11008 KB
subtask2_10.txt AC 83 ms 11008 KB
subtask2_11.txt AC 80 ms 10112 KB
subtask2_12.txt AC 61 ms 11008 KB
subtask2_13.txt AC 64 ms 10624 KB