Submission #897522

# Submission time Handle Problem Language Result Execution time Memory
897522 2024-01-03T10:47:47 Z Frosty_Jonson Money (IZhO17_money) C++14
0 / 100
0 ms 348 KB
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx,avx2")

#include <bits/stdc++.h>

#define pb push_back
using namespace std;
using ull = unsigned long long int;
using ll = long long;
#define full(x) x.begin(),x.end()
constexpr int MOD = 1e9 + 7;
#define gcd __gcd
#define ins insert
#define IOS cin.tie(NULL)->sync_with_stdio(false);
constexpr long double eps = 1e-7;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> list(n, 1);
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            if (a[i] >= a[j] && list[i] < list[j] + 1) {
                list[i] = list[j] + 1;
            }
        }
    }
    int max_length = *max_element(list.begin(), list.end());
    cout << n - max_length;
}

signed main() {
    clock_t startTime = clock();
    IOS
#ifdef fk
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int queries = 1;
    //cin >> queries;

    for (int test_case = 1; test_case <= queries; test_case++) {
        solve();
        cout << '\n';
    }
    //cout << "Time: " << ((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000) << " ms" << endl;
}
/*
 * 1 2 3 4 5 6
 * 1 3 5 2 4 6
 */

Compilation message

money.cpp: In function 'int main()':
money.cpp:37:13: warning: unused variable 'startTime' [-Wunused-variable]
   37 |     clock_t startTime = clock();
      |             ^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -