Submission #346550

#TimeUsernameProblemLanguageResultExecution timeMemory
346550Ca7Ac1A Huge Tower (CEOI10_tower)C++17
0 / 100
3 ms492 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #define ll signed long long using namespace std; const ll MOD = (ll)10e9 + 9; bool cmpr(ll a, ll b) { return a > b; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); freopen("tower.in", "r", stdin); ll N; ll D; cin >> N >> D; vector<ll> blocks(N, 0); for (ll i = 0; i < N; i++) { cin >> blocks[i]; } sort(blocks.begin(), blocks.end(), cmpr); vector<ll> possible(N, 0); ll sum = 1; ll j = 0; for (ll i = 0; i < N; i++) { j = max(j, i); sum = 1; while (j < N - 1 && blocks[i] - blocks[j + 1] <= D) { j++; sum *= (j - i + 1) % MOD; sum %= MOD; } possible[i] = sum; } ll sol = possible[0]; for (ll i = 1; i < N; i++) { if (blocks[i - 1] - blocks[i] <= D) { if (possible[i] != 1) { sol += possible[i]; } } else { sol *= possible[i]; } sol %= MOD; } cout << sol; }

Compilation message (stderr)

tower.cpp: In function 'int main()':
tower.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     freopen("tower.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...