Submission #952691

#TimeUsernameProblemLanguageResultExecution timeMemory
952691doducanhA Huge Tower (CEOI10_tower)C++14
30 / 100
197 ms10076 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mod=1e9+7; int a[1000005]; int n,k; main() { cin>>n>>k; for(int i=1;i<=n;i++)cin>>a[i]; sort(a+1,a+n+1); int r=0; int sol=1; for(int i=1;i<=n;i++){ while(r<n&&a[r+1]-a[i]<=k)r++; r=max(r,i); int dist=(r-i+1); sol=(sol*dist)%mod; } cout<<sol; return 0; }

Compilation message (stderr)

tower.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
#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...