fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #ifdef LOCAL_DEBUG
  5. #include "debug.h"
  6. #else
  7. #define debug(...)
  8. #endif
  9. #define endl '\n'
  10. using ll = long long;
  11.  
  12. // max(0.3*x,xāˆ’āŒŠ120*x*t/250*dāŒ‹āˆ’50w)
  13.  
  14. const long long D = 150;
  15. long long initial_scores[] = {750, 1250, 1500, 2000, 2500, 3000};
  16. long long tourist_times[] = {4, 13, 19, 38, 65, 134};
  17.  
  18. void solve() {
  19. for (int i = 0; i < 6; i++) {
  20. long double x = initial_scores[i];
  21. long double t = tourist_times[i];
  22. int wa = 0; // tourist doesn't get WA
  23. long double tourist_score = max(0.3 * x, x - floor(120 * x * t / (250 * D)) - 50 * wa);
  24. cout << "In problem " << (char)('A' + i) << " tourist's score was " << tourist_score << ", solving it in " << t << " minutes" << endl;
  25. long long L = t + 1, R = 1e9;
  26. long double score_to_lose = tourist_score - 6;
  27. long double time_to_lose = 1e9;
  28. while (L <= R) {
  29. long double m = (L + R) / 2;
  30. long double possible_score = max(0.3 * x, x - floor(120 * x * m / (250 * D)) - 50 * wa);
  31. if (possible_score <= score_to_lose) {
  32. time_to_lose = m;
  33. R = m - 1;
  34. } else {
  35. L = m + 1;
  36. }
  37. }
  38. cout << "If tourist took " << (time_to_lose - t) << " minutes more, he would have lost the 1st place" << endl;
  39. }
  40. }
  41.  
  42. int32_t main() {
  43. cin.tie(0)->sync_with_stdio(0);
  44. solve();
  45. /* cout << solve() << endl; */
  46. /* cout << (solve() ? "Yes" : "No") << endl; */
  47. }
  48.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
In problem A tourist's score was 741, solving it in 4 minutes
If tourist took 3 minutes more, he would have lost the 1st place
In problem B tourist's score was 1198, solving it in 13 minutes
If tourist took 2 minutes more, he would have lost the 1st place
In problem C tourist's score was 1409, solving it in 19 minutes
If tourist took 2 minutes more, he would have lost the 1st place
In problem D tourist's score was 1757, solving it in 38 minutes
If tourist took 1 minutes more, he would have lost the 1st place
In problem E tourist's score was 1980, solving it in 65 minutes
If tourist took 1 minutes more, he would have lost the 1st place
In problem F tourist's score was 1714, solving it in 134 minutes
If tourist took 1 minutes more, he would have lost the 1st place