Submission #709826

#TimeUsernameProblemLanguageResultExecution timeMemory
709826rainboySelf Study (JOI22_ho_t2)C11
100 / 100
238 ms9008 KiB
#include <stdio.h> #define N 300000 #define INF 0x3f3f3f3f3f3f3f3fLL int max(int a, int b) { return a > b ? a : b; } int solve(int *aa, int *bb, int n, int m, long long s) { int i; long long k_, k; k_ = (long long) n * m; for (i = 0; i < n; i++) { k = s <= (long long) aa[i] * m ? (s + aa[i] - 1) / aa[i] : m + (s - (long long) aa[i] * m + bb[i] - 1) / bb[i]; if (k_ < k) return 0; k_ -= k; } return 1; } int main() { static int aa[N], bb[N]; int n, m, i; long long lower, upper; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (i = 0; i < n; i++) { scanf("%d", &bb[i]); aa[i] = max(aa[i], bb[i]); } lower = 0, upper = INF; while (upper - lower > 1) { long long s = (lower + upper) / 2; if (solve(aa, bb, n, m, s)) lower = s; else upper = s; } printf("%lld\n", lower); return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:27:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:29:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
Main.c:31:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("%d", &bb[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#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...