# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
716151 | 2023-03-29T06:27:40 Z | ktkerem | K개의 묶음 (IZhO14_blocks) | C++17 | 1 ms | 340 KB |
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> typedef long long ll; typedef long double ld; typedef __int128 vll; typedef long long ftyp; typedef std::complex<ftyp> vec; #define llll std::pair<ll , ll> #define pb push_back #define fi first #define sec second #define cx real #define cy imag #define all(a) a.begin() , a.end() #define debug std::cout << "!!ALERT ALERT!!" << std::endl; const ll limit = 1e9+7; const ll sus = 1e5+5; std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); ll n , m;std::vector<ll> ar; ll dp[102][sus]; void solve(){ std::cin >> n >> m; ar.resize(n+1); dp[1][0] = limit; for(ll i = 1;n>=i;i++){ std::cin >> ar[i]; } dp[1][1] = ar[1]; for(ll i = 2;n>=i;i++){ dp[1][i] = std::max(dp[1][i-1] , ar[i]); } for(ll k = 2;m>=k;k++){ std::stack<ll> s1 , s2; for(ll j = 1;n>=j;j++){ ll ff = dp[k-1][j-1]; while(s1.size() && s1.top() < ar[j]){ ff = std::min(ff , s2.top()); s1.pop(); s2.pop(); } if(s1.empty() || ff + ar[j] <= s1.top() + s2.top()){ s1.push(ar[j]); s2.push(ff); } if(j >= k){ dp[k][j] = s1.top() + s2.top(); } } } std::cout << dp[m][n]; return;/**/ } int main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); ll t = 1; //std::cin >> t; while(t--){ solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 328 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Incorrect | 0 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 328 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 328 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 328 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Incorrect | 0 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 328 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Incorrect | 0 ms | 340 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |