Submission #954472

# Submission time Handle Problem Language Result Execution time Memory
954472 2024-03-28T02:51:54 Z vjudge1 Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main() {
  fastio;
  int n, m, i;
  cin >> n >> m;
  vector<int> poles;
  for (i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a - i * m > 0) {
        continue;
    }
    poles.push_back(a - i * m);
  }

//   for (i = 0; i < poles.size(); i++) {
//       cout << poles[i] << ' ';
//   }
//   cout << endl << endl;

  vector<int> s;
  vector<int> v (n + 1, 0);
  int last_used = 0;
  int best_ans = 0;
  for (i = 0; i < poles.size(); i++) {
    auto it = lower_bound(s.begin(), s.end(), poles[i]);
    if (it == s.end()) {
      //cout << "new deck" << endl;
      s.push_back(poles[i]);
      v[last_used]++;
      last_used++;
      best_ans = max(best_ans, 1);
      //cout << "bestans " << best_ans << endl;
      continue;
    }
    s[it - s.begin()] = poles[i];
    //cout << "inserted into deck " << it - s.begin() << '\n';
    v[it - s.begin()]++;
    best_ans = max(best_ans, v[it - s.begin()]);
    //cout << "best ans " << best_ans << endl;
  }

//   for (auto ss : s) {
//     cout << ss << ' ';
//   }
  
  //cout << endl << endl;
  cout << n - best_ans << '\n';
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for (i = 0; i < poles.size(); i++) {
      |               ~~^~~~~~~~~~~~~~
# 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 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 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -