제출 #1327296

#제출 시각아이디문제언어결과실행 시간메모리
1327296lywoemRoom Temperature (JOI24_ho_t1)C++17
35 / 100
1 ms332 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define l(a, b, i) for (ll i = a; i < b; i++)
#define rl(a, b, i) for (ll i = a; i >= b; i--)
#define vpair vector<pair<ll, ll>>
#define inf LLONG_MAX
#define ninf LLONG_MIN

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N, T; cin >> N >> T; vector<ll> vec(N);
    l(0, N, i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    if (T == 1) {
        cout << 0; return 0;
    }

    if (T == 2) {
        ll odd = 0, even = 0;
        l(0, N, i) {
            if (vec[i] % 2 == 1) odd++;
            else even++;
        }

        if (odd > 0 && even > 0) {
            cout << 1; return 0;
        }
        else {
            cout << 0; return 0;
        }
    }

    if (N == 2) {
        ll dif = vec[1] - vec[0];
        ll time = dif / T;
        ll time2 = time;
        if (dif % T > 0) time2++;

        cout << min(abs(vec[0] - (vec[1] - time * T)), abs((vec[0] - T) - (vec[1] - time2 * T)));
        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...