Submission #1067313

#TimeUsernameProblemLanguageResultExecution timeMemory
1067313kojacA Huge Tower (CEOI10_tower)C++17
100 / 100
103 ms19396 KiB
// #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define F first #define S second #define endl "\n" typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const ll LINF = 0x3f3f3f3f3f3f3f3f; const double EPS = 1e-9; const int INF = 0x3f3f3f3f; const ll MAXN = 2e5 + 10; const ll MOD = 1e9+9; const ll P = 333; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("shuffle.in","r",stdin); // freopen("shuffle.out","w",stdout); // int tt; // cin >> tt; // while(tt--){ ll n, m; cin >> n >> m; ll dp[n+5]; vector<ll> v; for(int i = 0; i < n; i++){ ll x; cin >> x; v.push_back(x); } sort(v.begin(), v.end()); ll l = n-1, r = n-1; while(l >= 0){ if(l == 0){ while(r >= l){ dp[r] = abs(r-l)+1; r--; } break; }else{ if(abs(v[r]-v[l-1]) <= m){ l--; }else{ dp[r] = abs(l-r)+1; r--; } } } for(int i = 1; i < n; i++){ dp[i] *= dp[i-1]; dp[i] %= MOD; } cout << dp[n-1] << endl; // } return 0; }
#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...