Submission #371414

# Submission time Handle Problem Language Result Execution time Memory
371414 2021-02-26T15:11:05 Z eulerdesoja A Huge Tower (CEOI10_tower) C++17
100 / 100
167 ms 8848 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;

#define ll long long
#define pb push_back
#define sz(x) int(x.size())

typedef pair<int,int>ii;
typedef vector<int> vi;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
const ll mod=1e9+9;
int32_t main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	//setIO("sort");
	int n,d;cin>>n>>d;
	vi a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a.begin(),a.end())	;
	int r=0;
	ll ans=1;
	for(int l=0;l<n;l++){
		while(r+1<n && a[r+1]-a[l]<=d)r++;
		ans=(ans*1ll*(r-l+1))%mod;
	}
	cout<<ans<<"\n";

	return 0;
}

Compilation message

tower.cpp: In function 'void setIO(std::string)':
tower.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1004 KB Output is correct
2 Correct 23 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 3796 KB Output is correct
2 Correct 60 ms 3804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 8848 KB Output is correct
2 Correct 167 ms 8212 KB Output is correct