답안 #570721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570721 2022-05-31T07:08:46 Z radaiosm7 Sure Bet (CEOI17_sure) C++
100 / 100
85 ms 3584 KB
#include <bits/stdc++.h>
using namespace std;
int n, i, j;
double a[100005];
double b[100005];
double ans, profa, profb;

int main() {
  scanf("%d", &n);

  for (i=0; i < n; ++i) {
    scanf("%lf", &a[i]);
    scanf("%lf", &b[i]);
  }

  sort(a, a+n, greater<double>());
  sort(b, b+n, greater<double>());
  ans = 0.0;
  i = 0;
  j = 0;

  while (i < n && j < n) {
    profa -= 1.0;
    profb -= 1.0;

    if (profa < profb) profa += a[i++];
    else profb += b[j++];
    ans = max(ans, min(profa, profb));
  }

  if (i == n) while (j < n) {
      profa -= 1.0;
      profb += b[j++]-1.0;
      ans = max(ans, min(profa, profb));
  }

  else if (j == n) while (i < n) {
      profa += a[i++]-1.0;
      profb -= 1.0;
      ans = max(ans, min(profa, profb));
  }

  printf("%.4lf\n", ans);
  return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
sure.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lf", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~~
sure.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lf", &b[i]);
      |     ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 64 ms 3200 KB Output is correct
18 Correct 64 ms 3212 KB Output is correct
19 Correct 64 ms 3196 KB Output is correct
20 Correct 65 ms 3152 KB Output is correct
21 Correct 84 ms 3584 KB Output is correct
22 Correct 66 ms 3140 KB Output is correct
23 Correct 72 ms 3168 KB Output is correct
24 Correct 60 ms 3092 KB Output is correct
25 Correct 85 ms 3184 KB Output is correct
26 Correct 76 ms 3532 KB Output is correct