Submission #870935

#TimeUsernameProblemLanguageResultExecution timeMemory
870935nhatvpmA Huge Tower (CEOI10_tower)C++17
100 / 100
95 ms8788 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld=long double; void setIO(string name) { freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int dx[]={1,-1,0,0},dy[]={0,0,1,-1}; void solve(){ int n,d,mod=1e9+9; cin>>n>>d; vector<int> a(n); for (int &z:a) cin>>z; sort(a.begin(),a.end()); int r=0; ll res=1; for (int l=0;l<n;l++){ while (r<n-1&&a[r+1]-a[l]<=d) r++; res=res*(r-l+1)%mod; } cout<<res; } int main(){ //setIO(""); ios_base::sync_with_stdio(0); cin.tie(0); int tc=1; //cin>>tc; while (tc--){ solve(); } }

Compilation message (stderr)

tower.cpp: In function 'void setIO(std::string)':
tower.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen((name+".out").c_str(),"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...