Submission #1053895

#TimeUsernameProblemLanguageResultExecution timeMemory
1053895NonozeRoom Temperature (JOI24_ho_t1)C++17
85 / 100
2036 ms9048 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; typedef long long ll; #define int long long #define sz(x) (int)(x.size()) #define debug(x) cerr << (#x) << ": " << (x) << endl #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() int calc(int a) { return a/2+a%2; } int n, T; vector<int> a; string s; void solve() { cin >> n >> T; a.resize(n); for (auto &u: a) cin >> u; if (n==2) { a[0]%=T, a[1]%=T; int act=calc(abs(a[0]-a[1])); act=min(act, calc(abs((a[0]+T)-a[1]))); act=min(act, calc(abs(a[0]-(a[1]+T)))); cout << act << endl; return; } int ans=LLONG_MAX; for (int t=0; t<2*T; t++) { int tot=0; for (int i=0; i<n; i++) { int act=abs(t-a[i]%T); act=min(act, abs(t-(a[i]%T+T))); tot=max(tot, act); } ans=min(ans, tot); } cout << ans << endl; return; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int tt=1;// cin >> tt; while(tt--) 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...