Submission #1156976

#TimeUsernameProblemLanguageResultExecution timeMemory
1156976mychecksedadRoom Temperature (JOI24_ho_t1)C++20
100 / 100
61 ms4172 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; int n; ll t, a[N]; ll get(ll x,ll y){ if(x>y) swap(x,y); return min((y-x+1)/2, (x+t-y+1)/2); } void solve(){ cin >> n >> t; for(int i = 1; i <= n; ++i){ cin >> a[i]; a[i] %= t; } sort(a+1, a+1+n); ll ans = (a[n]-a[1]+1)/2; for(int i = 1; i < n; ++i){ ans = min(ans, (a[i] + t - a[i + 1] + 1)/2); } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; 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...