Submission #152909

# Submission time Handle Problem Language Result Execution time Memory
152909 2019-09-10T12:41:08 Z luciocf Pairs (IOI07_pairs) C++14
30 / 100
28 ms 1656 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+10;

int x[maxn];

int main(void)
{
	int b, n, d, m;
	scanf("%d %d %d %d", &b, &n, &d, &m);

	for (int i = 1; i <= n; i++)
		scanf("%d", &x[i]);

	sort(x+1, x+n+1);

	long long ans = 0;

	int l = 1, r = 2;
	while (l <= n && r <= n)
	{
		if (l != r && x[r]-x[l] <= d)
			ans += 1ll*(r-l);

		if (x[r]-x[l] <= d) r++;
		else l++;
	}

	printf("%lld\n", ans);
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d", &b, &n, &d, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1016 KB Output is correct
2 Correct 20 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1656 KB Output is correct
2 Correct 27 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1600 KB Output is correct
2 Correct 28 ms 1600 KB Output is correct
3 Correct 26 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 1400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -