Submission #54534

# Submission time Handle Problem Language Result Execution time Memory
54534 2018-07-04T03:50:14 Z 윤교준(#1492) Pairs (IOI07_pairs) C++11
30 / 100
26 ms 1072 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)))
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct TC1 {
	TC1(int N, int L, int M) : N(N), L(L), M(M) { init(); }

	int A[100005];

	ll Ans;
	int N, L, M;

	void init() {
		Ans = 0;
		fill(A, A+100005, 0);
	}
	void run() {
		for(int i = 1; i <= N; i++) cin >> A[i];
		sort(A+1, A+N+1);

		for(int i = 1, j = 1; i <= N; i++) {
			for(; j <= N && A[j] <= A[i]+L; j++);
			Ans += j-i-1;
		}

		cout << Ans << endl;
	}
};

int K, N, L, M;

int main() {
    //freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);

	cin >> K >> N >> L >> M;

	if(1 == K) {
		TC1 tc1(N, L, M);
		tc1.run();
	}
	else if(2 == K);
	else;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 636 KB Output is correct
2 Correct 3 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 988 KB Output is correct
2 Correct 16 ms 988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 988 KB Output is correct
2 Correct 23 ms 988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 988 KB Output is correct
2 Correct 23 ms 988 KB Output is correct
3 Correct 22 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -