Submission #74405

# Submission time Handle Problem Language Result Execution time Memory
74405 2018-08-31T16:11:49 Z nixys Studentsko (COCI14_studentsko) C++11
100 / 100
6 ms 1004 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

typedef pair <int, int> pii;
typedef long long ll;

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 5001;

int n, k;
int a[MAXN];
vector <pii> v;
vector <int> najmanji;

int main(){

    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        v.pb(mp(a[i], i));
    }

    sort(v.begin(), v.end());

    for (int i = 0; i < n; i++)
        a[v[i].se] = (i/k)+1;

    najmanji.pb(-inf);

    for (int i = 0; i < n; i++){
        vector<int>::iterator it = upper_bound(najmanji.begin(), najmanji.end(), a[i]);
        if (it == najmanji.end()) najmanji.pb(a[i]);
        else *it = a[i];
    }

    cout << n - najmanji.size() + 1;

    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 644 KB Output is correct
2 Correct 5 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 720 KB Output is correct
2 Correct 5 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 764 KB Output is correct
2 Correct 5 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 832 KB Output is correct
2 Correct 6 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1004 KB Output is correct
2 Correct 6 ms 1004 KB Output is correct