답안 #960228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960228 2024-04-10T00:12:26 Z ezzzay Akcija (COCI15_akcija) C++14
80 / 80
30 ms 4112 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
int dp[N];
signed main(){
	int n;
	cin>>n;
	vector<int>v;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		v.pb(a);
	}
	sort(v.begin(),v.end(),greater<int>());
	dp[1]=v[0];
	dp[2]=v[0]+v[1];
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+v[i-1],dp[i-3]+v[i-2]+v[i-3]);
	}
	cout<<dp[n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 21 ms 3784 KB Output is correct
7 Correct 17 ms 3792 KB Output is correct
8 Correct 18 ms 4112 KB Output is correct
9 Correct 30 ms 4048 KB Output is correct
10 Correct 26 ms 4048 KB Output is correct