답안 #772306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
772306 2023-07-03T23:37:50 Z tolbi 학생 (COCI14_studentsko) C++17
100 / 100
164 ms 972 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define int long long
#define vint(x) vector<int> x
#define endl '\n'
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define revarr(x) reverse(x.begin(), x.rend())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tol(x) (1ll<<((int)(bi)))
#define det(x) cout<<"NO\0YES"+((!!x)*3)<<endl;
#define INF LONG_LONG_MAX
using namespace std;
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
	ios;
	int T = 1;
	if (!T) cin>>T;
	int tno = 0;
	while (T-(tno++)){
		deci(n);deci(k);
		vint(arr(n));
		cinarr(arr);
		map<int,int> mp;
		vint(carr)=arr;
		sortarr(carr);
		for (int i = 0; i < n; ++i)
		{
			mp[carr[i]]=i;
		}
		for (int i = 0; i < n; ++i)
		{
			arr[i]=mp[arr[i]];
		}
		vector<int> ayni(n,-1);
		vector<int> sonr(n,-1);
		vector<int> gor(n/k+1,n);
		for (int i = n-1; i >= 0; i--){
			ayni[i]=gor[arr[i]/k];
			sonr[i]=gor[arr[i]/k+1];
			gor[arr[i]/k]=i;
		}
		vector<int> dp(n,1);
		for (int i = 0; i < n; i++){
			for (int j = 0; j < i; j++){
				if (arr[j]/k<=arr[i]/k){
					dp[i]=max(dp[i],dp[j]+1);
				}
			}
		}
		cout<<n-*max_element(dp.begin(), dp.end())<<endl;
	}
}

Compilation message

studentsko.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 816 KB Output is correct
2 Correct 132 ms 816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 852 KB Output is correct
2 Correct 164 ms 880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 852 KB Output is correct
2 Correct 92 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 864 KB Output is correct
2 Correct 142 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 852 KB Output is correct
2 Correct 139 ms 972 KB Output is correct