Submission #1002906

#TimeUsernameProblemLanguageResultExecution timeMemory
1002906OwstinA Huge Tower (CEOI10_tower)C++14
30 / 100
68 ms11344 KiB
#include <bits/stdc++.h> #include <cstdio> #include <ext/pb_ds/assoc_container.hpp> #define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0) #define pb push_back #define all(x) begin(x), end(x) #define umap unordered_map #define space " " #define TEST_CASES int a; cin >> a; for (int i = 0; i < a; i++) {solve(); cout << endl;} using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define MOD (ll)(1e9 + 7) void solve() { ll b, c; cin >> b >> c; vector<ll> vec(b); for (int i = 0; i < b; i++){ cin >> vec[i]; } sort(all(vec)); ll res = 1; int curr = b - 1; for (int i = b - 1; i >= 0; i--){ while (curr > 0 && vec[i] - vec[curr - 1] <= c){ curr--; } res = res * (i - curr + 1) % MOD; } cout << res; } int main() { FAST_IO; //freopen("sabotage.in", "r", stdin); //freopen("sabotage.out", "w", stdout); //TEST_CASES; solve(); cout << endl; /*int a; cin >> a; for (int i = 1; i <= a; i++){ cout << "Case #" << i << ": "; solve(); }*/ }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...