제출 #1320309

#제출 시각아이디문제언어결과실행 시간메모리
1320309aryanRoom Temperature (JOI24_ho_t1)C++20
5 / 100
1 ms332 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,t; cin >> n >> t; vector<int> a(n); for(int i = 0;i < n;i++){ cin >> a[i]; a[i] %= t; } sort(a.begin(),a.end()); int ans = t - 1; for(int i = 0;i < n - 1;i++){ // if ith is left point int s = a[i]; int e = t - 1; while(e > s){ int mid = (s + e + 1) / 2; int k = (t - (mid - a[i])); int ba = mid - k; bool ok = a[i + 1] >= ba; if(ok){ s = mid; }else{ e = mid - 1; } } ans = min(ans,(t - (e - a[i]))); } for(int i = 1;i < n;i++){ // if ith is right point int s = 0; int e = a[i]; while(e > s){ int mid = (s + e) / 2; int k = (t - (a[i] - mid)); int ba = mid + k; bool ok = a[i - 1]; if(ok){ e = mid; }else{ s = mid + 1; } } ans = min(ans,(t - (a[i] - s))); } cout << ans << '\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...