Submission #1083917

# Submission time Handle Problem Language Result Execution time Memory
1083917 2024-09-04T14:11:03 Z nqknht Rabbit Carrot (LMIO19_triusis) C++14
14 / 100
197 ms 216660 KB
#include <bits/stdc++.h>

#define ll long long
#define fi first
#define se second

const ll I = 2e5 + 9;

using namespace std;

ll n, M, a[I];
vector<pair<ll, ll>> box[I];

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> M;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    box[0].push_back({0, 0});
    for (int i = 1; i <= n; i++)
    {
        int sw = 0;
        for (auto z : box[i - 1]) // first = cnt, second = ending
        {
            if (a[i] - z.se > M)
                box[i].push_back({z.fi + 1, z.se + M});
            else if (a[i] - z.se <= M)
            {
                if (sw == 0)
                {
                    box[i].push_back({z.fi, a[i]});
                    sw = 1;
                }
                if(a[i] - z.se != M)
                box[i].push_back({z.fi + 1, z.se + M});
            }
        }
    }
    ll rs = 10000000;
    for(int i = 0; i < box[n].size(); i ++)
        rs = min(rs, box[n][i].fi);
    cout << rs;
    return 0;
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0; i < box[n].size(); i ++)
      |                    ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4952 KB Output is correct
8 Correct 1 ms 4952 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4952 KB Output is correct
8 Correct 1 ms 4952 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 140 ms 147028 KB Output is correct
21 Correct 197 ms 216660 KB Output is correct
22 Correct 2 ms 5212 KB Output is correct
23 Correct 190 ms 216568 KB Output is correct
24 Correct 195 ms 216644 KB Output is correct
25 Incorrect 186 ms 212116 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 140 ms 147028 KB Output is correct
5 Correct 197 ms 216660 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 190 ms 216568 KB Output is correct
8 Correct 195 ms 216644 KB Output is correct
9 Incorrect 186 ms 212116 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 140 ms 147028 KB Output is correct
5 Correct 197 ms 216660 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 190 ms 216568 KB Output is correct
8 Correct 195 ms 216644 KB Output is correct
9 Incorrect 186 ms 212116 KB Output isn't correct
10 Halted 0 ms 0 KB -