Submission #865564

#TimeUsernameProblemLanguageResultExecution timeMemory
865564nase7farajA Huge Tower (CEOI10_tower)C++14
100 / 100
98 ms8884 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define pll pair<long long , long long> #define pii pair<int , int> #define mii map <int , int> #define mll map <long long , long long> #define vi vector <int> #define vl vector <long long> #define pb push_back #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define rev greater<int>() #define RF(F) freopen(F , "r" , stdin ) #define WF(F) freopen(F , "w" , stdout) using namespace std ; const ll INF = 1e9 ; const int eps = 1e-7 ; const int mod = 1e9 + 9 ; const int MAX_N = 1e6 + 7 ; int a[MAX_N] ; void solve(int testCase){ int n , k ; scanf("%d %d" , &n , &k) ; for(int i = 0 ; i < n ; i ++){ scanf("%d" , &a[i]) ; } sort(a , a + n) ; int l = 0 , r = 0 ; ll ans = 1 ; while(l < n){ while (r < n - 1 && (a[r + 1] - a[l]) <= k)r ++ ; ans = ans * (r - l + 1) ; ans %= mod ; l ++ ; } printf("%lld\n" , ans) ; } int main() { int testCase = 1 ; for(int T = 1 ; T <= testCase ; T ++){ solve(T) ; } return 0 ; }

Compilation message (stderr)

tower.cpp: In function 'void solve(int)':
tower.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d %d" , &n , &k) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
tower.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d" , &a[i]) ;
      |         ~~~~~^~~~~~~~~~~~~~
#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...