Submission #481078

#TimeUsernameProblemLanguageResultExecution timeMemory
481078sparsh_67A Huge Tower (CEOI10_tower)C++14
100 / 100
146 ms20884 KiB
/* 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 (stderr)

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 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...