Submission #756645

# Submission time Handle Problem Language Result Execution time Memory
756645 2023-06-12T03:36:39 Z SanguineChameleon Pairs (IOI07_pairs) C++17
30 / 100
28 ms 1572 KB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

namespace sub1 {
	const int maxN = 1e5 + 20;
	int pos[maxN];
	int N, D, M;

	void solve() {
		cin >> N >> D >> M;
		for (int i = 1; i <= N; i++) {
			cin >> pos[i];
		}
		sort(pos + 1, pos + N + 1);
		long long res = 0;
		for (int i = 1; i <= N; i++) {
			res += upper_bound(pos + 1, pos + N + 1, pos[i] + D) - lower_bound(pos + 1, pos + N + 1, pos[i] - D);
		}
		res = (res - N) / 2;
		cout << res;
	}
}

namespace sub2 {
	void solve() {
		assert(false);
	}
}

namespace sub3 {
	void solve() {
		assert(false);
	}
}

void just_do_it() {
	int B;
	cin >> B;
	if (B == 1) {
		sub1::solve();
	}
	if (B == 2) {
		sub2::solve();
	}
	if (B == 3) {
		sub3::solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1064 KB Output is correct
2 Correct 16 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1564 KB Output is correct
2 Correct 21 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1476 KB Output is correct
2 Correct 23 ms 1572 KB Output is correct
3 Correct 24 ms 1496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -