Task: | Järjestys |
Sender: | Mahtimursu |
Submission time: | 2020-11-27 18:26:54 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 26 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 26 |
#2 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1, 2 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 2 | details |
Code
#include <bits/stdc++.h>typedef long long ll;#define M 1000000007using namespace std;void test_case() {int n, x;cin >> n >> x;vector<int> v(n);for (int i = 0; i < n; ++i) {cin >> v[i]; // muista vaihtaa main}}int nums[8];bool used[8];int cur[8];int ans;int n, x;void rec(int p) {if (n == p) {ans++;}for (int i = 0; i < n; ++i) {if (used[i]) continue;if (cur[p-1] - x > nums[i]) continue;used[i] = 1;cur[p] = nums[i];rec(p+1);used[i] = 0;}}void slow() {cin >> n >> x;ans = 0;for (int i = 0; i < n; ++i) {cin >> nums[i];cur[i] = 0;used[i] = 0;}for (int i = 0; i < n; ++i) {used[i] = 1;cur[0] = nums[i];rec(1);used[i] = 0;}cout << ans;}int main() {ios_base::sync_with_stdio(false);cin.tie(0);int t;cin >> t;for (int i = 0; i < t; ++i) {slow();cout << "\n";}return 0;}
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: TIME LIMIT EXCEEDED
input |
---|
100 85 980 570 804 393 119 973 743 345 46... |
correct output |
---|
753889928 541098438 241592657 827522722 403761060 ... |
user output |
---|
(empty) |
Test 3
Group: 2
Verdict: TIME LIMIT EXCEEDED
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 |
---|
(empty) |