제출 #847565

#제출 시각아이디문제언어결과실행 시간메모리
847565jmao142857Rabbit Carrot (LMIO19_triusis)C++14
100 / 100
22 ms7008 KiB
// 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;
    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();
}

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'int main()':
triusis.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 0; i < nums.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...