| Task: | Järjestys |
| Sender: | kluopaja |
| Submission time: | 2020-11-27 23:24:20 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 26 |
| #2 | ACCEPTED | 74 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2 | details |
| #2 | ACCEPTED | 0.01 s | 2 | details |
| #3 | ACCEPTED | 0.01 s | 2 | details |
Compiler report
input/code.cpp: In function 'int solve(std::vector<int>, int)':
input/code.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0; j < i; ++j) {
~~^~~Code
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9+7;
int solve(vector<int> v, int x) {
ll ans = 1;
sort(v.begin(), v.end());
for(std::size_t i = 0; i < v.size(); ++i) {
ll ok_places = 1;
for(int j = 0; j < i; ++j) {
if(v[i] - v[j] <= x) ++ok_places;
}
ans *= ok_places;
ans %= MOD;
}
return ans;
}
int main() {
int tt;
cin >> tt;
for(int xx = 0; xx < tt; ++xx) {
int n, x;
cin >> n >> x;
vector<int> v;
for(int i = 0; i < n; ++i) {
int tmp;
cin >> tmp;
v.push_back(tmp);
}
cout << solve(v, x) << endl;
}
}
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
| input |
|---|
| 100 5 20 65 49 97 55 9 6 33 42 32 10 92 60 37 ... |
| correct output |
|---|
| 6 192 4 72 288 ... |
| user output |
|---|
| 6 192 4 72 288 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 100 85 980 570 804 393 119 973 743 345 46... |
| correct output |
|---|
| 753889928 541098438 241592657 827522722 403761060 ... |
| user output |
|---|
| 753889928 541098438 241592657 827522722 403761060 ... Truncated |
Test 3
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 100 100 1 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 988185646 196898158 546822979 56844088 346866189 ... |
| user output |
|---|
| 988185646 196898158 546822979 56844088 346866189 ... Truncated |
