답안 #477523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
477523 2021-10-02T11:41:19 Z hjc4vr 학생 (COCI14_studentsko) C++14
0 / 100
13 ms 440 KB
#include <bits/stdc++.h>
using namespace std;
int ft[5005];
int query(int x){
    int ans=0;
    for (;x!=0;x-=x&(-x)) ans = max(ft[x],ans);
    return ans;
}
void insert(int x,int val){
    for (;x<=5004;x+=x&(-x)) ft[x] = max(ft[x],val);
}

bool s(pair<int,int> &a,pair<int,int> &b){
    if (a.first < b.first){
        return true;
    }
    else if (a.first == b.first){
        return a.second < b.second;
    }else{
        return false;
    }

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,k;cin>>n>>k;
    pair<int,int> arr[n+1];
    for (int i=1;i<=n;++i) {
        int a;
        cin >> a;
        arr[i] = make_pair(a,i);
    }
    sort(arr+1,arr+n+1);
    int t=1,cnt=k;
    pair<int,int> v[n+1];
    for (int i=1;i<=n;++i){
        v[arr[i].second] = make_pair(t,arr[i].second);
        cnt--;
        if (cnt==0){
            t+=1;
            cnt=k;
        }
    }
    sort(v+1,v+n+1,s);
    for (int i=1;i<=n;++i){
        cout << v[i].first << ' ' << v[i].second << endl;
        int maxi = query(v[i].second);
        insert(v[i].second,maxi+1);
    }
    cout << n - query(n);
}
    
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 440 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -