/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 580.0 KiB
#2 Accepted 6ms 1.973 MiB
#3 Time Exceeded ≥1095ms ≥17.262 MiB
#4 Accepted 239ms 12.512 MiB
#5 Accepted 176ms 15.23 MiB
#6 Accepted 1ms 532.0 KiB
#7 Time Exceeded ≥1086ms ≥17.133 MiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

vector<array<int, 4>> v;

void BaseCases() {
    v.push_back({0, 0, 3, 0});
    v.push_back({1, 1, 2, 0});
    v.push_back({3, 0, 2, 0});
    v.push_back({0, 0, 1, 2});
    v.push_back({1, 1, 1, 1});
    v.push_back({3, 0, 1, 1});
    v.push_back({0, 3, 1, 0});
    v.push_back({2, 2, 1, 0});
    v.push_back({4, 1, 1, 0});
    v.push_back({6, 0, 1, 0});
    v.push_back({1, 1, 0, 2});
    v.push_back({3, 0, 0, 2});
    v.push_back({2, 2, 0, 1});
    v.push_back({4, 1, 0, 1});
    v.push_back({6, 0, 0, 1});
    v.push_back({1, 4, 0, 0});
    v.push_back({3, 3, 0, 0});
    v.push_back({5, 2, 0, 0});
    v.push_back({7, 1, 0, 0});
    v.push_back({9, 0, 0, 0});
}

int dp[51][51][51][51];
int a, b, c, d;

void solve(int cs) {
  cin >> a >> b >> c >> d;

  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        for (int l = 0; l <= d; ++l) {
          for (auto &x : v) {
            if (i >= x[0] && j >= x[1] && k >= x[2] && l >= x[3]) {
              dp[i][j][k][l] = max(dp[i][j][k][l], dp[i - x[0]][j - x[1]][k - x[2]][l - x[3]] + 1);
            }
          }
        }
      }
    }
  }

  cout << "Case " << cs << ": " << dp[a][b][c][d] << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  BaseCases();
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1014 FIFA World Cup 2022 Again!
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-13 09:05:22
Judged At
2024-11-11 03:26:35
Judged By
Score
5
Total Time
≥1095ms
Peak Memory
≥17.262 MiB