Submission #369261

#TimeUsernameProblemLanguageResultExecution timeMemory
369261notrichardpengA Huge Tower (CEOI10_tower)C++11
25 / 100
1042 ms4600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pi pair<int, int> #define endl '\n' void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if (name.length()) { freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } int n, d; vector<int> A; const int MOD = 1e9 + 9; int main(){ setIO(""); cin >> n >> d; for(int i = 0; i < n; i++){ int a; cin >> a; A.push_back(a); } sort(A.begin(), A.end(), greater<int>()); int l = 0, r = 0; int res = 1; while(r < n){ while(r < n && A[l] - A[r] <= d) r++; int diff = r - l; while(diff > 1){ res *= diff; res %= MOD; diff--; } while(l < r && A[l] - A[r] > d) l++; } cout << res << endl; return 0; }

Compilation message (stderr)

tower.cpp: In function 'void setIO(std::string)':
tower.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   12 |         freopen((name+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         freopen((name+".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...