답안 #924330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924330 2024-02-08T20:53:50 Z JakobZorz 조교 (CEOI16_popeala) C++17
17 / 100
2000 ms 17240 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
 
int n,t,s;
int pts[20000];
bool done[50][20000];
ll done2[20000];
ll dp[51][20001];
ll cost[51][20001];
 
void solve(){
    cin>>n>>t>>s;
    for(int i=0;i<t;i++)
        cin>>pts[i];
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        for(int j=0;j<t;j++){
            done[i][j]=str[j]=='1';
            if(str[j]=='1')
                done2[j]+=1LL<<i;
        }
    }
    
    for(int i=0;i<51;i++)
        for(int j=0;j<20001;j++)
            dp[i][j]=1e18;
    
    dp[0][0]=0;
    
    for(int num=1;num<=s;num++){
        for(int i=0;i<=t;i++)
            for(int p=0;p<=n;p++)
                cost[p][i]=dp[num-1][i];
        
        for(int i=0;i<=t;i++){
            ll ppl=(1LL<<n)-1;
            for(int j=i-1;j>=0;j--){
                ppl&=done2[j];
                int ppl_active=__builtin_popcountll(ppl);
                //cost[ppl_active][j]=dp[num-1][j]+csum*ppl_active;
                dp[num][i]=min(dp[num][i],cost[ppl_active][j]);
            }
            
            for(int j=i;j>=0;j--){
                for(int p=0;p<=n;p++){
                    cost[p][j]+=pts[i]*p;
                }
            }
        }
    }
    
    for(int i=0;i<s;i++)
        cout<<dp[i+1][t]<<"\n";
}
 
int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("input.in","r",stdin);freopen("output.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}
 
/*
 
2 3 3
4 3 5
101
110
 
 
0
8
16
 
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12632 KB Output is correct
2 Correct 3 ms 16848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 17028 KB Output is correct
2 Correct 280 ms 16984 KB Output is correct
3 Correct 293 ms 17240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2051 ms 16988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12632 KB Output is correct
2 Correct 3 ms 16848 KB Output is correct
3 Correct 286 ms 17028 KB Output is correct
4 Correct 280 ms 16984 KB Output is correct
5 Correct 293 ms 17240 KB Output is correct
6 Execution timed out 2051 ms 16988 KB Time limit exceeded
7 Halted 0 ms 0 KB -