Submission #847563

# Submission time Handle Problem Language Result Execution time Memory
847563 2023-09-10T00:59:10 Z jmao142857 Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 344 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);

    ll N, M; cin >> N >> M;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        nums[i] = M * i - a;
    }

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

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         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 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -