제출 #1002518

#제출 시각아이디문제언어결과실행 시간메모리
1002518kwongwengRoom Temperature (JOI24_ho_t1)C++17
100 / 100
86 ms7248 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef vector<vector<ll>> vll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define pb push_back #define ms memset #define fi first #define se second ll MOD = 998244353; ll power(ll base, ll n){ base %= MOD; if (n==0) return 1; ll halfn = power(base,n/2); if (n%2==0) return (halfn*halfn)%MOD; return (((halfn*halfn)%MOD)*base)%MOD; } void solve(){ int n,T; cin>>n>>T; vi a(n); FOR(i,0,n) cin>>a[i]; FOR(i,0,n) a[i]%=T; sort(a.begin(), a.end()); int ans = a[n-1]-a[0]; FOR(i,0,n-1){ ans = min(ans, T+a[i]-a[i+1]); } cout<<(ans+1)/2<<"\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TC = 1; //cin>>TC; while (TC--){ solve(); } 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...