/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 4.574 MiB
#2 Time Exceeded ≥1014ms ≥24.691 MiB
#3 Time Exceeded ≥1030ms ≥596.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#ifdef LOCAL
    #include "debug.h"    
#else
    #define print(...)
    #define printt(...)
#endif

#define int long long

vector<array<int, 4>> v = {
    {9, 0, 0, 0},
    {7, 1, 0, 0},
    {5, 2, 0, 0},
    {3, 3, 0, 0},
    {1, 4, 0, 0},
    
    {6, 0, 0, 1},
    {4, 1, 0, 1},
    {2, 2, 0, 1},
    {0, 3, 0, 1},
    {3, 0, 1, 1},
    {1, 2, 1, 1},

    {3, 0, 0, 2},
    {0, 0, 1, 2},
    {1, 1, 0, 2},
    
    {0, 0, 3, 0},
    {3, 0, 2, 0},
    {1, 1, 2, 0},
    {6, 0, 1, 0},
    {4, 1, 1, 0},
    {2, 2, 1, 0},
    {0, 3, 1, 0},

    {1, 1, 1, 1}
};

int dp[50][50][50][50];

int DP(int a, int b, int c, int d) {
    if(a < 0 or b < 0 or c < 0 or d < 0)return -1;

    if(a == 0 and b == 0 and c == 0 and d == 0) return 0;

    int res = 0;
    for(auto &[i, j, k, l] : v) {
        if(i <= a and j <= b and k <= c and l <= d) {
            res = max(res, DP(a - i, b - j, c - k, d - l) + 1);
        }
    }

    return dp[a][b][c][d] = res;
}

void run(){
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << DP(a, b, c, d) << endl;   
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1, cs = 1;
    cin >> t;
    
    while( t --> 0 ) {
        cout << "Case " << cs++ << ": ";
        run();
    }
    
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1014 FIFA World Cup 2022 Again!
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-10 12:01:35
Judged At
2025-01-10 18:01:05
Judged By
Score
1
Total Time
≥1030ms
Peak Memory
≥24.691 MiB