Submission #847564

# Submission time Handle Problem Language Result Execution time Memory
847564 2023-09-10T01:06:33 Z jmao142857 Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
190 ms 34476 KB
// https://oj.uz/problem/view/LMIO19_triusis
// Rabbit Carrot

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <climits>

using namespace std;
using ll = long long;

void setIO(string s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    setIO("problemname");

    ll N, M; cin >> N >> M;
    vector<ll> nums;
    for (int i = 0; i < N; i++) {
        int a; cin >> a; int x = M * (i + 1) - a;
        if (x >= 0) nums.push_back(x);
    }

    vector<ll> dp;
    for (int i = 0; i < nums.size(); i++) {
        int index = upper_bound(dp.begin(), dp.end(), nums[i]) - dp.begin();
        if (index == dp.size()) dp.push_back(nums[i]);
        else dp[index] = nums[i];
    }

    cout << N - dp.size();
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < nums.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
triusis.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (index == dp.size()) dp.push_back(nums[i]);
      |             ~~~~~~^~~~~~~~~~~~
triusis.cpp: In function 'void setIO(std::string)':
triusis.cpp:20:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:21:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  freopen((s + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 34476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 34476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 34476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 34476 KB Output isn't correct
2 Halted 0 ms 0 KB -