Submission #262607

# Submission time Handle Problem Language Result Execution time Memory
262607 2020-08-13T05:12:31 Z 송준혁(#5085) Pairs (IOI07_pairs) C++17
30 / 100
33 ms 1440 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, D;
int A[101010];
LL ans;

int main(){
	scanf("%*d %d %d %*d", &N, &D);
	for (int i=1; i<=N; i++) scanf("%d", &A[i]);
	sort(A+1, A+N+1);
	int l=1, r=1;
	for (int i=1; i<=N; i++){
		while (A[i]-A[l] > D) l++;
		while (r<=N && A[r]-A[i] <= D) r++;
		ans += r-l;
	}
	printf("%lld\n", (ans-N)/2);
	return 0;
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%*d %d %d %*d", &N, &D);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:12:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  for (int i=1; i<=N; i++) scanf("%d", &A[i]);
      |                           ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1152 KB Output is correct
2 Correct 19 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1408 KB Output is correct
2 Correct 27 ms 1440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1440 KB Output is correct
2 Correct 33 ms 1436 KB Output is correct
3 Correct 26 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 1280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -