Submission #481077

# Submission time Handle Problem Language Result Execution time Memory
481077 2021-10-19T12:06:20 Z sparsh_67 A Huge Tower (CEOI10_tower) C++14
0 / 100
278 ms 106544 KB
/*
start of cp 3.0BETA
NEW-BETA-LADDER
https://codeforces.com/problemset/page/2?tags=1800-1800
DEAD PERSON CODING
*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define MOD 1000000009
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define graph vector<vector<int>>
#define print(s) for(auto it:s) cout<<it<<" "
#define print2(s) for(auto it:s) cout<<it.fi<<" : "<<it.se
#define uset unordered_set
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vi,greater<int>>
#define ln cout<<'\n'
#define space cout<<" "
#define len(x) x.size()
#define bits(x) __builtin_popcountll(x)
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
graph g;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    fileio();
    int n,d;
    cin>>n>>d;
    vi a(n,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    vi p(n,0);
    int l=0,r=0;
    while(l<n){
        while(r<n and a[r]-a[l]<=d)r++;
        p[l]=r-l;
        l++;
    }
    int j=0;
    vi best(n,0);
    for(int i=0;i<n;i++){
        while(j<n and j<i+p[i])best[j++]=i;
    }
    int res=1;
    for(int i=0;i<n;i++){
        res=(res*(i-best[i]+1))%MOD;
    }
    cout<<res;

    return 0;
}

        

Compilation message

tower.cpp: In function 'void fileio()':
tower.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 229 ms 106408 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 106412 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 243 ms 106404 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 106512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 106544 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 217 ms 106416 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 265 ms 106516 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 216 ms 106404 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 106532 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 238 ms 106516 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 215 ms 106436 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 226 ms 106412 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 106536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 234 ms 106512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 106508 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 255 ms 106508 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 249 ms 106416 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 106436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 106420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 237 ms 106416 KB Output isn't correct
2 Halted 0 ms 0 KB -