답안 #1013912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013912 2024-07-04T08:03:43 Z Baytoro Room Temperature (JOI24_ho_t1) C++17
100 / 100
390 ms 32848 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define int ll
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
const int N=2e5+5;
void solve(){
    int n,t;cin>>n>>t;
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        a[i]%=t;
    }
    sort(rall(a));
    int ans=1e9;
    multiset<int> st;
    for(int i=0;i<n;i++) st.insert(a[i]);
    for(int i=-1;i<n;i++) {
        if(i>=0) {
            st.erase(st.find(a[i]));
            a[i]-=t;
            st.insert(a[i]);
        }
        int l=*st.begin(),r=*st.rbegin();
        int md=(l+r)/2;
        int res=max(abs(l-md),abs(r-md));
        ans=min(ans,res);
        /*vector<int> b;
        for(int j=0;j<n;j++) {
            b.pb(a[j]);
        }
        sort(all(b));
        int md=(b[b.size()-1]+b[0])/2;
        int res=0;
        for(int j=0;j<n;j++) res=max(abs(a[j]-md),res);
        ans=min(ans,res);*/
    }
    cout<<ans<<endl;
}
signed main(){
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
}
//#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 432 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 2 ms 444 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 448 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 432 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 2 ms 444 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 448 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 364 ms 32528 KB Output is correct
46 Correct 352 ms 32592 KB Output is correct
47 Correct 390 ms 32492 KB Output is correct
48 Correct 288 ms 32592 KB Output is correct
49 Correct 334 ms 32616 KB Output is correct
50 Correct 376 ms 32500 KB Output is correct
51 Correct 349 ms 32592 KB Output is correct
52 Correct 258 ms 32432 KB Output is correct
53 Correct 273 ms 32848 KB Output is correct