제출 #1324371

#제출 시각아이디문제언어결과실행 시간메모리
1324371ttrioRoom Temperature (JOI24_ho_t1)C++20
100 / 100
70 ms4652 KiB
#include <bits/stdc++.h>
using namespace std;
 
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define imax INT_MAX
#define llmax LLONG_MAX
#define int unsigned long long
#define ld long double
#define pq priority_queue
#define inf 1e18
//#define MOD 1000000007
#define maxn 1000005
#define all(v) v.begin,v.end()

const long long INF=1e18;
const int MAXN = 1000005; 

 
typedef long long ll;
using namespace std;

int n;
int ft[101];

int qry(int p){
	int sum=0;
	for(;p;p-=(p&-p))sum+=ft[p];
	return sum;
}

void upd(int p,int v){
	for(;p<=100;p+=(p&-p))ft[p]+=v;
}
		

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	
	int n,t;cin>>n>>t;
	vector<int> v;
	
	for(int i=0;i<n;i++){
			int a;cin>>a;
			v.pb(a%t);
	}
	
	sort(v.begin(),v.end());
	int m=0,gap=0;
	for(int i=1;i<n;i++)m=max(m,v[i]-v[i-1]);
	gap = t-(v[n-1]-v[0]);
	m=max(gap,m);
	cout<<((t-m)+1)/2;
	
	
	return 0;
}
#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...