Submission #857033


Source Code Expand

Copy
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include <utility>
#include <cstdio>
#include<algorithm>
#define mi 9000000000LL*1000000000
#define ma -9000000000LL*1000000000

using namespace std;
	int n,l,q;
int main(){
    cin>>n;
    vector<int> x(n+1);
    for(int i=0; i<n; i++)scanf("%d", &x[i+1]);
    cin>>l>>q;
    vector<int> a(q), b(q);
    for(int i=0; i<q; i++){
	scanf("%d %d", &a[i] , &b[i]);
	if(a[i]>b[i])swap(a[i], b[i]);
	int x1 = x[a[i]], x2 = x[b[i]];
	int res=0;
	while(true){
	    int ind = upper_bound(x.begin()+a[i], x.begin()+b[i]+1, x1+l)-x.begin();
	    res++; 
	    if(ind == x.size() || ind-1>=b[i])break;
//	    cout<<ind<<" "<<res<<" "<<x1<<"\n";
	    x1 = x[ind-1]; a[i]=ind-1;
	    
	}
	printf("%d\n", res);
    }
}

Submission Info

Submission Time
Task E - Tak and Hotels
User bas
Language C++14 (GCC 5.4.1)
Score 200
Code Size 799 Byte
Status TLE
Exec Time 3157 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0; i<n; i++)scanf("%d", &x[i+1]);
                                               ^
./Main.cpp:20:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &a[i] , &b[i]);
                               ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 18
TLE × 9
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 4 ms 256 KB
subtask1_01.txt AC 6 ms 256 KB
subtask1_02.txt AC 4 ms 256 KB
subtask1_03.txt AC 5 ms 256 KB
subtask1_04.txt AC 11 ms 256 KB
subtask1_05.txt AC 5 ms 256 KB
subtask1_06.txt AC 6 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 4 ms 256 KB
subtask1_09.txt AC 7 ms 256 KB
subtask1_10.txt AC 11 ms 256 KB
subtask1_11.txt AC 11 ms 256 KB
subtask1_12.txt AC 11 ms 256 KB
subtask1_13.txt AC 10 ms 256 KB
subtask2_01.txt TLE 3153 ms 1536 KB
subtask2_02.txt TLE 3156 ms 1408 KB
subtask2_03.txt AC 2668 ms 1792 KB
subtask2_04.txt AC 54 ms 1152 KB
subtask2_05.txt TLE 3153 ms 1152 KB
subtask2_06.txt AC 81 ms 1664 KB
subtask2_07.txt TLE 3153 ms 1408 KB
subtask2_08.txt TLE 3153 ms 1408 KB
subtask2_09.txt TLE 3153 ms 1408 KB
subtask2_10.txt TLE 3157 ms 1408 KB
subtask2_11.txt TLE 3153 ms 1408 KB
subtask2_12.txt TLE 3153 ms 1408 KB
subtask2_13.txt AC 94 ms 1536 KB