Submission #239098

# Submission time Handle Problem Language Result Execution time Memory
239098 2020-06-14T11:34:43 Z T0p_ Pairs (IOI07_pairs) C++14
30 / 100
41 ms 1664 KB
#include<bits/stdc++.h>
using namespace std;

int arr[100100];

int main()
{
	int t, n, k, m;
	long long ans = 0;
	scanf(" %d %d %d %d",&t,&n,&k,&m);
	if(t == 1)
	{
		for(int i=1 ; i<=n ; i++)
			scanf(" %d",&arr[i]);
		sort(arr+1, arr+n+1);
		for(int i=1 ; i<=n ; i++)
		{
			int l = i, r = n;
			while(l != r)
			{
				int mid = (l+r+1)>>1;
				if(arr[mid] <= arr[i]+k) l = mid;
				else r = mid-1;
			}
			ans += l-i;
		}
		printf("%lld\n",ans);
		return 0;
	}
	return 0;
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d %d %d %d",&t,&n,&k,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:14:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %d",&arr[i]);
    ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1024 KB Output is correct
2 Correct 25 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1536 KB Output is correct
2 Correct 32 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1576 KB Output is correct
2 Correct 35 ms 1536 KB Output is correct
3 Correct 39 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -