Submission #605463

# Submission time Handle Problem Language Result Execution time Memory
605463 2022-07-25T18:04:24 Z krit3379 A Huge Tower (CEOI10_tower) C++17
100 / 100
114 ms 8064 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 1000005

int a[N];
long long mod=1e9+9,ans=1;

int main(){
    int n,d,i,pos;
    scanf("%d %d",&n,&d);
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    pos=1;
    for(i=1;i<=n;i++){
        while(pos<i&&a[pos]+d<a[i])pos++;
        ans=ans*(i-pos+1)%mod;
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d",&n,&d);
      |     ~~~~~^~~~~~~~~~~~~~~
tower.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%d",&a[i]);
      |                      ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 468 KB Output is correct
2 Correct 12 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 1552 KB Output is correct
2 Correct 55 ms 3720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 6612 KB Output is correct
2 Correct 114 ms 8064 KB Output is correct