## Submission #1084148

# Submission time Handle Problem Language Result Execution time Memory
1084148 2024-09-05T11:38:39 Z yoav_s Financial Report (JOI21_financial) C++17
5 / 100
154 ms 58704 KB
```#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> p;
typedef pair<ll, p> tri;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<p> vp;
typedef vector<tri> vtri;
typedef vector<vtri> vvtri;
typedef vector<vvtri> vvvtri;
typedef vector<vv> vvv;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vvb> vvvb;
typedef vector<p> vp;
typedef vector<vp> vvp;
typedef vector<vvp> vvvp;
typedef vector<vvvp> vvvvp;

#define double long double
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;

const ll mod = 1e9 + 7;
const ll INF = 1e18;

#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define loop(a) for (ll i = 0; i < a; i++)
#define setmin(a, b) a = min(a, b)
#define setmax(a, b) a = max(a, b)
#define all(v) v.begin(), v.end()

void update(v &st, ll i, ll val)
{
ll n = st.size() / 2;
i += n;
st[i] = val;
i /= 2;
while (i > 0)
{
st[i] = min(st[2 * i], st[2 * i + 1]);
i /= 2;
}
}

ll query(v &st, ll l, ll r)
{
ll n=  st.size() / 2;
l += n; r += n;
ll res = INF;
while (l <= r)
{
if (l % 2 == 1)
{
res = min(res, st[l]);
l++;
}
if (r % 2 == 0)
{
res = min(res, st[r]);
r--;
}
l /= 2; r /= 2;
}
return res;
}

ll lastSmaller(v &st, ll x)
{
ll i = 1;
ll n = st.size() / 2;
if (st[1] >= x) return -1;
while (i < n)
{
if (st[2 * i + 1] < x) i = 2 * i + 1;
else i *= 2;
}
return i - n;
}

int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll N, D;
cin >> N >> D;
v A(N);
for (ll i =0; i < N; i++) cin >> A[i];
ll n = pow(2, ceil(log2(N + 1)));
v st(2 * n, INF);
update(st, 0, -INF);
vector<multiset<ll>> endings(N + 1);
endings[0].insert(-INF);
for (ll i = 1; i <= N; i++) endings[i].insert(INF);
v res(N, -1);
ll best = 0;
for (ll  i = 0; i < N; i++)
{
{
best = max(best, add + 1);
}
if (i >= D && res[i - D] != -1)
{
endings[res[i - D]].erase(endings[res[i - D]].find(A[i - D]));
update(st, res[i - D], *endings[res[i - D]].begin());
}
}
cout << best << "\n";
return 0;
}```

#### Subtask #1 0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -

#### Subtask #2 0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -

#### Subtask #3 0 / 20.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -

#### Subtask #4 0 / 12.0

# Verdict Execution time Memory Grader output
1 Correct 127 ms 44236 KB Output is correct
2 Incorrect 103 ms 44012 KB Output isn't correct
3 Halted 0 ms 0 KB -

#### Subtask #5 5.0 / 5.0

# Verdict Execution time Memory Grader output
1 Correct 137 ms 58704 KB Output is correct
2 Correct 154 ms 58396 KB Output is correct
3 Correct 153 ms 58452 KB Output is correct
4 Correct 154 ms 58452 KB Output is correct
5 Correct 136 ms 58456 KB Output is correct
6 Correct 137 ms 58304 KB Output is correct
7 Correct 85 ms 58344 KB Output is correct
8 Correct 127 ms 58532 KB Output is correct
9 Correct 95 ms 57948 KB Output is correct
10 Correct 107 ms 58192 KB Output is correct
11 Correct 148 ms 58448 KB Output is correct
12 Correct 101 ms 58448 KB Output is correct

#### Subtask #6 0 / 35.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -