# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1083917 | nqknht | Rabbit Carrot (LMIO19_triusis) | C++14 | 197 ms | 216660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |