Submission #1091294

# Submission time Handle Problem Language Result Execution time Memory
1091294 2024-09-20T12:10:38 Z owieczka Gap (APIO16_gap) C++17
100 / 100
38 ms 3276 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> points;

long long findGap(int T, int N)
{
   if (T == 1)
   {
      ll s = 0;
      ll t = 1e18;
      ll mn, mx;
      ll n = 0;
      MinMax(s, t, &mn, &mx);
      n += 2;
      s = mn;
      t = mx;
      ll m = 0;
      while (n < N)
      {
         MinMax(s+1, t-1, &mn, &mx);
         n += 2;
         m = max(m, mn - s);
         m = max(m, t - mx);
         s = mn;
         t = mx;
      }
      m = max(m, mx - mn);
      return m;
   }

   ll s = 0;
   ll t = 1e18;
   ll b, e;
   ll n = N;
   MinMax(s, t, &b, &e);
   // musze podzielic na przedziały
   ll prz = (e - b)/n + 1;
   ll mn, mx;
   points.push_back(b);
   for (ll i = b + 1; i < e; i+=prz)
   {
      MinMax(i, i + prz - 1, &mn, &mx);
      if (mn != -1)
         points.push_back(mn);
      if (mx != -1)
         points.push_back(mx);
   }
   points.push_back(e);
   mx = 0;
   for (ll i = 1; i < points.size(); i++)
   {
      mx = max(points[i] - points[i-1], mx);
   }
   return mx;
}

//1000000000000000000
//250'000'000'000'000'001

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:52:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    for (ll i = 1; i < points.size(); i++)
      |                   ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 6 ms 440 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 6 ms 600 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 6 ms 600 KB Output is correct
21 Correct 37 ms 1052 KB Output is correct
22 Correct 32 ms 1112 KB Output is correct
23 Correct 28 ms 1112 KB Output is correct
24 Correct 25 ms 1112 KB Output is correct
25 Correct 23 ms 1112 KB Output is correct
26 Correct 26 ms 1112 KB Output is correct
27 Correct 27 ms 1112 KB Output is correct
28 Correct 25 ms 1112 KB Output is correct
29 Correct 25 ms 1112 KB Output is correct
30 Correct 21 ms 1112 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 496 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 10 ms 956 KB Output is correct
17 Correct 10 ms 980 KB Output is correct
18 Correct 9 ms 980 KB Output is correct
19 Correct 9 ms 980 KB Output is correct
20 Correct 5 ms 852 KB Output is correct
21 Correct 35 ms 2256 KB Output is correct
22 Correct 35 ms 2256 KB Output is correct
23 Correct 36 ms 2256 KB Output is correct
24 Correct 36 ms 2204 KB Output is correct
25 Correct 36 ms 3276 KB Output is correct
26 Correct 37 ms 2248 KB Output is correct
27 Correct 36 ms 2256 KB Output is correct
28 Correct 36 ms 2248 KB Output is correct
29 Correct 38 ms 2248 KB Output is correct
30 Correct 27 ms 1616 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct