Submission #1109889

# Submission time Handle Problem Language Result Execution time Memory
1109889 2024-11-08T02:45:26 Z Wendidiask Studentsko (COCI14_studentsko) C++14
100 / 100
34 ms 2812 KB
/*
                                     :---:--:--::::::--:-:----:                                     
                               ::-:::.                         ::-:::                               
                       .*  -===..                                    :---                           
                     .-+*##=-------====-:                                :--:                       
                  :+##=.* -=            :=+-                                .-=:                    
               .+++-.  :-   -=.            .=+-                                .--.                 
             .++=-     +      -=              :*-                                 :-.               
            +*+-      :-        -=.             -*:                                 :=:             
           #*:        *           -=.             +-                                  .=            
        =:%+         -:             -=.            +-                                   --          
        -%:          *                -=.           *:                                    +.        
       :%-..        =.                  -=.          #                                     -:       
      :=#   ..      +                     -=.        ==                                     -=      
     ---+     .    =                        -=.      .#                                      .+     
    -: ==       .  =         :------::------:.-=.     %                                       .=    
   :-  ==        .=.     ---:.               :--#+.  .%                                        :-   
   =   .*        .+.. :=-                        :++ -+                                         =:  
  +     #.       +  -=:                            :*%-*:                                        *  
 :=     :#      :=:=   .                    :-----: =+-+                                         .+ 
 *       -*     *=-     . .-        :::::::.       :*  .#+.                                       + 
:-        -+   :#.        --::-----:              :*     ++=                                      .-
+          :*. *.    .:::::*%:                   ++       +.-=.                                    +
+           -#**----:       .=                 -*.         +  -=                                   =
*           +.#=+:           +  .           .=+:           =.   -=.                                =
=            -+  :++:         +   ..     .=+=              .=     -=.                              -
=            %-     :====-:.  =.  .:--===-                  *       -=.                            -
+           +--          .:--==#==-:.=                      +         -=.                          =
*           + *                =.    :                     .=           -=.                        =
+          =  *                 +                          =              -=.                      +
:-         =  .=                =:                         =                -=.                   .-
 *        +    =:                *                        *                   -=.                 + 
 :-      .+     =-               :-                     .+                      -=.              .+ 
  *      *       :=               *                    :=                         -=             *  
   =    :-         =:             .-                 .=:                            -=.         =:  
   -:   *           .=-            +               .=-                                -=       :-   
    =: -:              --:         :-           :--:                                    -=.   .=    
     =:+                  ----.     *       :---.                                         -= .+     
    --=*----------------------=*+=--=+--=+*+------------------------------------------------%+:.    
    :: :=                           +:-                                                    -- :.    
        .=.                                                                               =.        
          -=                                                                            -=          
           .=:                                                                        .=.           
             .=:                                                                    .+:             
               :--                                                                :-:               
                  --                                                            -=.                 
                    :--.                                                     --:                    
                       :--:                                              .--:                       
                          .-:-:                                      ::--.                          
                               :----.                          .:----                               
                                    .:::::::::-::::::--::::::::.                             
 */
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define int long long
#define debug(x) cerr << #x << " is " << x << "\n"
#define hehe ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repb(i, a, b) for (int i = b; i >= a; i--)
#define pii pair<int, int>
#define linebreak cout << "---------------------------------------------------------\n"
#define f first
#define s second
#define pb push_back
#define START auto start = high_resolution_clock::now();
#define END cout << '\n'; auto stop = high_resolution_clock::now(); auto duration = duration_cast<microseconds>(stop - start); long double time = duration.count();cout << "Time taken: " << time/1000000.0 << " seconds" << '\n';
// good luck
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const int MS = 2e5+5, mod = 1e9+7;
int n, k, a[MS], dp[MS];
pii p[MS];
int32_t main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> p[i].f; p[i].s = i;
	}
	sort(p+1, p+n+1); 
	int cnt = 1; a[p[1].s] = cnt;
	for (int i = 2; i <= n; i++) {
		if ((i-1)%k == 0) cnt++;
		a[p[i].s] = cnt;
	}
	dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		dp[i] = 1;
		for (int j = 1; j < i; j++) {
			if (a[j] <= a[i]) dp[i] = max(dp[i], dp[j]+1); 
		}
	}
	cout << n-*max_element(dp+1, dp+n+1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2808 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2640 KB Output is correct
2 Correct 27 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2640 KB Output is correct
2 Correct 33 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2812 KB Output is correct
2 Correct 16 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2640 KB Output is correct
2 Correct 32 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2640 KB Output is correct
2 Correct 34 ms 2656 KB Output is correct