제출 #1147859

#제출 시각아이디문제언어결과실행 시간메모리
1147859minggaSelf Study (JOI22_ho_t2)C++20
100 / 100
114 ms5136 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 3e5 + 7; int n, m, a[N], b[N]; bool check(long long mid) { long long cnt = 0; for (int i = 1; i <= n; ++i) { if (1ll * a[i] * m >= mid) { long long x = (1ll * a[i] * m - mid) / a[i]; cnt += x; } } for (int i = 1; i <= n; ++i) { if (1ll * a[i] * m < mid) { long long need = mid - 1ll * a[i] * m; need = (need + b[i] - 1) / b[i]; cnt -= need; if (cnt < 0) return 0; } } return cnt >= 0; } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) cin >> b[i], a[i] = max(a[i], b[i]); int l = 0, r = 1e18, ans = 0; while(l <= r) { int m = (l + r) >> 1; if(check(m)) { ans = m; l = m + 1; } else r = m - 1; } cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

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

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