Submission #1083926

#TimeUsernameProblemLanguageResultExecution timeMemory
1083926nqknhtRabbit Carrot (LMIO19_triusis)C++14
14 / 100
346 ms262144 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second const ll I = 2e5 + 9; using namespace std; int n, M, a[I]; vector<pair<int, int>> box[I]; bool mark[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++) { for(int j = i - 1; j >= 0; j --) mark[j] = false; 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 (!mark[z.fi]) { box[i].push_back({z.fi, a[i]}); mark[z.fi] = 1; } if(a[i] - z.se != M) box[i].push_back({z.fi + 1, z.se + M}); } } } int rs = 10000000; for(int i = 0; i < box[n].size(); i ++) rs = min(rs, box[n][i].fi); cout << rs; return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i = 0; i < box[n].size(); i ++)
      |                    ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...