Submission #1127452

#TimeUsernameProblemLanguageResultExecution timeMemory
1127452mateuszwesRoom Temperature (JOI24_ho_t1)C++20
100 / 100
101 ms8504 KiB
#include <bits/stdc++.h> #define ld long double #define ll long long #define ull unsigned long long #define i128 __int128 #define F first #define S second #define pb push_back #define pf push_front #define pi pair<int,int> #define pl pair<ll,ll> #define pq priority_queue using namespace std; constexpr ll M = 1e9+7; ll n, t; inline ll mod(ll a){ return ((a%t)+t)%t; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> t; vector<ll> ok(n); for(int i = 0; i < n; i++){ cin >> ok[i]; ok[i] = mod(ok[i]); } sort(ok.begin(), ok.end()); deque<ll> git; for(auto k: ok) git.pb(k); ll score = M; for(int i = 0; i <= n+1; i++){ ll a1 = max(git.back()-(git.back()+git.front())/2, (git.back()+git.front())/2-git.front()); ll a2 = max(git.back()-(git.back()+git.front())/2-1, (git.back()+git.front())/2-git.front()+1); score = min({score,a1,a2}); git.pb(git.front()+t); git.pop_front(); } cout << score << '\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...