제출 #1264361

#제출 시각아이디문제언어결과실행 시간메모리
1264361tminhRoom Temperature (JOI24_ho_t1)C++20
35 / 100
1 ms328 KiB
#include "bits/stdc++.h" using namespace std; #define task "" #define ll long long #define endl '\n' #define fi first #define se second #define vall(a) (a).begin(), (a).end() #define sze(a) (int)a.size() #define pii pair<int, int> #define pll pair<ll, ll> #define ep emplace_back #define pb push_back #define pf push_front const ll mod = 1e9 + 7; const int N = 1e6 + 5; const ll oo = 1e18; bool START; int n, t, ans; map<int, bool> mp; vector<int> arr; inline void solve() { for (auto[val, cnt] : mp) arr.pb(val); int ans = t; for (int val : arr) { ans = min(ans, max(min(abs(arr[0] - val), abs((t - arr[0]) - val)), min(abs(arr.back() - val), abs((t - arr.back()) - val)))); val = t - val; ans = min(ans, max(min(abs(arr[0] - val), abs((t - arr[0]) - val)), min(abs(arr.back() - val), abs((t - arr.back()) - val)))); } cout << ans; } inline void input() { cin >> n >> t; ans = 0; for (int i = 1; i <= n; ++i) { int x; cin >> x; x %= t; x = min(x, t - x); mp[x] = true; } return solve(); } bool END; int main() { if(fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); input(); cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl; cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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