# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1248654 | Bui_Quoc_Cuong | Room Temperature (JOI24_ho_t1) | C++20 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i, a, b) for (int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for (int i = a; i >= (int)b; i--)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
const int N = 5e5 + 5;
int n, T;
void init(){
cin >> n >> T;
}
int a[N], pre[N];
void process(){
for(int i = 1; i <= n; i++){
int x; cin >> x;
a[x % T]++;
}
for(int i = 0; i < T; i++){
a[i + T] = a[i];
}
for(int i = 0; i <= 2 * T; i++){
pre[i] = pre[i - 1] + a[i];
}
int ans = 2e9;
for(int i = 0; i < T; i++){
int l = i, r = i + T - 1, res = - 1;
while(l <= r){
int mid = (l + r) >> 1;
if(pre[mid] - pre[i - 1] >= n) res = mid, r = mid - 1;
else l = mid + 1;
}
if (res != - 1) ans = min(ans, res - i + 1);
}
cout << ans / 2;
}
signed main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define taskname "kieuoanh"
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
init();
process();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |