Submission #363977

# Submission time Handle Problem Language Result Execution time Memory
363977 2021-02-07T17:47:32 Z MaisyDoge13 A Huge Tower (CEOI10_tower) C++17
0 / 100
4 ms 492 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <cmath>
#include <climits>
#include <algorithm>
#include <array>
#include <set>
#include <map>
using namespace std;

#define input "tower.in"
#define output "tower.out"
#define int long long
#define MOD (int)(1e9+9)
int n, k;
vector<int> a;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen(input, "r", stdin);
    freopen(output, "w", stdout);
    cin >> n >> k;
    a.reserve(n+1);
    for (int i=0;i<n;i++) {
        int x; cin >> x;
        a.push_back(x);
    }
    a.push_back(LLONG_MAX);
    sort(a.begin(), a.end());
    int ans=1,r=1,l=0;
    while (r<=n) {
        //cout << "l r " << l << ' ' << r << endl;
        int blocks = r-l;//when this is the base and all the previous ones have been used, this is the size to build
        if (a[l]+k>a[r]) r++;
        else if (a[l]+k<=a[r]) {
            ans*=blocks;
            l++;
            if (r==l) r++;
        }
    }
    cout << ans%MOD << endl;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     freopen(input, "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
tower.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     freopen(output, "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -