제출 #1152884

#제출 시각아이디문제언어결과실행 시간메모리
1152884asdasd수열 (APIO14_sequence)C++20
0 / 100
0 ms324 KiB
//gm --- akezhon #include <bits/stdc++.h> // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define pf push_front #define F first #define S second #define all(v) v.begin(),v.end() #define pii pair<int,int> #define tm (tl+tr)/2 #define TL v+v, tl, tm #define TR v+v+1, tm+1, tr #define DA l <= tl && tr <= r #define NE r < tl || tr < l #define double long double #define int long long using namespace std; const int N=5e5+7; const int mod=998244353; const int inf=2e18; int n, k; int a[N]; int p[N]; int dp[10005][205]; int pe[10005][205]; void AlemAmenov(){ cin >> n >> k; for(int i=1; i <= n; i++){ cin >> a[i]; p[i]=p[i-1]+a[i]; } int mx=0, pos=0; for(int kk=1; kk <= k; kk++){ for(int i=1; i <= n; i++){ for(int j=0; j < i; j++){ int val = (p[n]-p[i])*(p[i]-p[j]) + dp[j][kk-1]; if(dp[i][kk] <= val){ dp[i][kk] = val; pe[i][kk] = j; } } if(mx <= dp[i][k]){ mx=dp[i][k]; pos=i; } } } cout << mx << '\n'; while(pos){ cout << pos << ' '; pos = pe[pos][k--]; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int RealName=1; // cin >> RealName; // srand(time(0)); while(RealName--) AlemAmenov(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...