Submission #347406

#TimeUsernameProblemLanguageResultExecution timeMemory
347406danielsuhA Huge Tower (CEOI10_tower)C++17
100 / 100
140 ms16124 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define mpa make_pair #define pb push_back #define ins insert #define f first #define s second #define all(x) x.begin(), x.end() #define nl "\n" #define int ll const int inf = numeric_limits<int>::max(); void fileIO(string filename) { freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } const ll MOD = 1e9 + 9; void solve() { int n, d; cin >> n >> d; vector<int> a(n, 0); for(int i = 0; i < n; i++) { cin >> a[i]; } sort(all(a), greater<>()); vector<int> mult(n, 1); int r = 0; for(int l = 0; l < n; l++) { while(r < n && a[l] - a[r] <= d) { r++; } mult[l] = r - l; } int ans = 1; for(int i = n - 1; i >= 0; i--) { ans *= mult[i] % MOD; ans %= MOD; } cout << ans % MOD; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); //fileIO(""); int tc = 1; //cin >> tc; for(int i = 1; i <= tc; i++) { solve(); } }

Compilation message (stderr)

tower.cpp: In function 'void fileIO(std::string)':
tower.cpp:20:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  freopen((filename + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:21:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  freopen((filename + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...