제출 #1248654

#제출 시각아이디문제언어결과실행 시간메모리
1248654Bui_Quoc_CuongRoom Temperature (JOI24_ho_t1)C++20
70 / 100
1 ms328 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) 메시지

Main.cpp: In function 'int main()':
Main.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...