#include <bits/stdc++.h>
using namespace std;
int t1,t5,t10;
int n;
int t;
int ans;
int vis[705][155][55];
int dfs(int k,int n1,int n5,int n10,int num)
{
    if(n1 < 0 || n5 < 0 || n10 < 0)
    {
        return 99999999;
    }

    if(k == n)
    {
        return num;
    }

    if(vis[n1][n5][n10] != 0 && vis[n1][n5][n10] <= num)
    {
        return vis[n1][n5][n10];    
    }

    int ret = 99999999;
    ret = min(ret,dfs(k + 1,n1 + 2,n5,n10 - 1,num + 1));
    ret = min(ret,dfs(k + 1,n1 + 2,n5 - 2,n10,num + 2));
    ret = min(ret,dfs(k + 1,n1 - 3,n5 + 1,n10 - 1,num + 4));
    ret = min(ret,dfs(k + 1,n1 - 3,n5 - 1,n10,num + 4));
    
    ret = min(ret,dfs(k + 1,n1 - 8,n5,n10,num + 8));

    return vis[n1][n5][n10] = ret;
}
void solve()
{
    //memset(vis,0x3f3f3f3f,sizeof vis);
    cin >> n >> t1 >> t5 >> t10;
    if(t1 + t5 * 5 + t10 * 10 < 8 * n) cout << -1 << '\n';
    else cout << dfs(0,t1,t5,t10,0) << '\n';
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> t;
    while(t--) solve();
    return 0;
}

会编译错误,C++20可以编译,请问是技术原因还是个人原因

5 条评论

  • 1