제출 #1296861

#제출 시각아이디문제언어결과실행 시간메모리
1296861wedonttalkanymoreMoney (IZhO17_money)C++20
0 / 100
1 ms576 KiB
#include <bits/stdc++.h>
/*
    Checklist: 
    - Check statement: 
    - Check filename: 
    - Check test limit: 
    - Stresstest: 
*/
using namespace std;
using ll = long long;

#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second

const ll N = 1e6 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19;

int n, a[N];
vector <pii> tmp;
int b[N];
int dp[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) tmp.emplace_back(a[i], i);
    sort(tmp.begin(), tmp.end());
    for (int i = 1; i <= n; i++) {
        int pos = tmp[i - 1].se;
        b[pos] = i;
        // cout << pos << ' ' << b[pos] << '\n';
    }
    // for (int i = 1; i <= n; i++) cout << b[i] << ' ';
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int val = b[i];
        dp[val] = dp[val - 1] + 1;
        ans = max(ans, dp[val]);
    }
    cout << n - ans;
    return 0; 
}

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

money.cpp: In function 'int main()':
money.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
money.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(".out", "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...