답안 #270934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
270934 2020-08-18T04:13:23 Z leductoan 학생 (COCI14_studentsko) C++14
100 / 100
47 ms 516 KB
#include<bits/stdc++.h>
using namespace std;
#define task ""
#define BIT(x, i) (((x) >> (i)) & 1)
#define lb lower_bound
#define ub upper_bound
#define lla(v) (v).begin(),(v).end()
#define zs(v) (v).size()
#define fi first
#define se second
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007; /// 998244353
const int base=311;
const int N=1e5+5;

pii a[5005];
int n,k,b[5005],dp[5005];
void solved()
{
    cin>>n>>k;
    for(int i=0;i<n;++i) cin>>a[i].fi,a[i].se=i;
    sort(a,a+n);
    for(int i=0;i<n;++i) b[a[i].se]=i/k;
    int ans=0;
    for(int i=0;i<n;++i)
    {
        dp[i]=1;
        for(int j=0;j<i;++j)
            if(b[j]<=b[i]) dp[i]=max(dp[i],dp[j]+1);
        ans=max(ans,dp[i]);
    }
    cout<<n-ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solved();
}

Compilation message

studentsko.cpp: In function 'int main()':
studentsko.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   42 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
studentsko.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   43 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 504 KB Output is correct
2 Correct 38 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 512 KB Output is correct
2 Correct 47 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 512 KB Output is correct
2 Correct 27 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 464 KB Output is correct
2 Correct 44 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 512 KB Output is correct
2 Correct 44 ms 416 KB Output is correct