제출 #676739

#제출 시각아이디문제언어결과실행 시간메모리
676739asteilindRabbit Carrot (LMIO19_triusis)C++17
0 / 100
0 ms320 KiB
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <set>
#include <numeric>
#include <bitset>
#include <climits>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define MOD 1000000007
using namespace std;
void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    if(name.length()){
        freopen((name+".in").c_str(), "r", stdin); // see Input & Output
        freopen((name+".out").c_str(), "w", stdout);
    }
}
void solve()
{
    int n; cin >> n; ll ju; cin >> ju;
    vector<ll> poles(n);
    vector<int> dp(n);
    forn(i,n)
    {
        cin >> poles[i];
        dp[i] = 1;
    }
    int maxv = 1;
    for (int i=0 ; n>i ; i++)
    {
        for (int j=0 ; i>j ; j++)
        {
            
            if (poles[j] >= poles[i] || poles[i]-poles[j] < ju)
            {
                
                dp[i] = max(dp[i],dp[j]+1);
                maxv = max(dp[i],maxv);
                
            }
        }
    }
    cout << n-maxv << endl;
    }

int main()
{
    setIO();
    solve();
}


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

triusis.cpp: In function 'void setIO(std::string)':
triusis.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((name+".in").c_str(), "r", stdin); // see Input & Output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen((name+".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...