QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#133896#4931. Comic BingepssxxCompile Error//C++172.2kb2023-08-02 16:48:072023-08-02 16:48:11

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 16:48:11]
  • 评测
  • [2023-08-02 16:48:07]
  • 提交

answer


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e3 + 7;
int T = 1, n, m;
int dp[maxn][maxn * 10][2];
int a[maxn], b[maxn];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    memset(dp, 0x3f, sizeof dp);
    dp[0][0][0] = 0;
    int sumb = 0;
    for(int i = 1; i <= n; i++) {
        sumb += b[i];
        for(int j = 0; j <= sumb; j++) {
            if(j >= b[i]) dp[i][j][1] = max(min(dp[i - 1][j - b[i]][1], dp[i - 1][j - b[i]][0]), j) + a[i];
            dp[i][j][0] = dp[i - 1][j][1] + a[i];
        }
    }
    int ans = inf;
    for(int i = b[i]; i <= n * 10; i++) ans = min(ans, dp[n][i][1]);
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 
    // cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e3 + 7;
int T = 1, n, m;
int dp[maxn][maxn * 10][2];
int a[maxn], b[maxn];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    memset(dp, 0x3f, sizeof dp);
    dp[0][0][0] = 0;
    int sumb = 0;
    for(int i = 1; i <= n; i++) {
        sumb += b[i];
        for(int j = 0; j <= sumb; j++) {
            if(j >= b[i]) dp[i][j][1] = max(min(dp[i - 1][j - b[i]][1], dp[i - 1][j - b[i]][0]), j) + a[i];
            dp[i][j][0] = dp[i - 1][j][1] + a[i];
        }
    }
    int ans = inf;
    for(int i = b[i]; i <= n * 10; i++) ans = min(ans, dp[n][i][1]);
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 
    // cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Details

answer.code:52:14: error: redefinition of ‘const double PI’
   52 | const double PI = acos(-1.0);
      |              ^~
answer.code:7:14: note: ‘const double PI’ previously defined here
    7 | const double PI = acos(-1.0);
      |              ^~
answer.code:53:14: error: redefinition of ‘const double eps’
   53 | const double eps = 1e-6;
      |              ^~~
answer.code:8:14: note: ‘const double eps’ previously defined here
    8 | const double eps = 1e-6;
      |              ^~~
answer.code:54:11: error: redefinition of ‘const int mod’
   54 | const int mod = 1e9 + 7;
      |           ^~~
answer.code:9:11: note: ‘const int mod’ previously defined here
    9 | const int mod = 1e9 + 7;
      |           ^~~
answer.code:55:11: error: redefinition of ‘const int inf’
   55 | const int inf = 0x3f3f3f3f;
      |           ^~~
answer.code:10:11: note: ‘const int inf’ previously defined here
   10 | const int inf = 0x3f3f3f3f;
      |           ^~~
answer.code:56:17: error: redefinition of ‘const long long int INF’
   56 | const long long INF = 0x3f3f3f3f3f3f3f3f;
      |                 ^~~
answer.code:11:17: note: ‘const long long int INF’ previously defined here
   11 | const long long INF = 0x3f3f3f3f3f3f3f3f;
      |                 ^~~
answer.code:57:11: error: redefinition of ‘const int maxn’
   57 | const int maxn = 1e3 + 7;
      |           ^~~~
answer.code:12:11: note: ‘const int maxn’ previously defined here
   12 | const int maxn = 1e3 + 7;
      |           ^~~~
answer.code:58:5: error: redefinition of ‘int T’
   58 | int T = 1, n, m;
      |     ^
answer.code:13:5: note: ‘int T’ previously defined here
   13 | int T = 1, n, m;
      |     ^
answer.code:58:12: error: redefinition of ‘int n’
   58 | int T = 1, n, m;
      |            ^
answer.code:13:12: note: ‘int n’ previously declared here
   13 | int T = 1, n, m;
      |            ^
answer.code:58:15: error: redefinition of ‘int m’
   58 | int T = 1, n, m;
      |               ^
answer.code:13:15: note: ‘int m’ previously declared here
   13 | int T = 1, n, m;
      |               ^
answer.code:59:5: error: redefinition of ‘int dp [1007][10070][2]’
   59 | int dp[maxn][maxn * 10][2];
      |     ^~
answer.code:14:5: note: ‘int dp [1007][10070][2]’ previously declared here
   14 | int dp[maxn][maxn * 10][2];
      |     ^~
answer.code:60:5: error: redefinition of ‘int a [1007]’
   60 | int a[maxn], b[maxn];
      |     ^
answer.code:15:5: note: ‘int a [1007]’ previously declared here
   15 | int a[maxn], b[maxn];
      |     ^
answer.code:60:14: error: redefinition of ‘int b [1007]’
   60 | int a[maxn], b[maxn];
      |              ^
answer.code:15:14: note: ‘int b [1007]’ previously declared here
   15 | int a[maxn], b[maxn];
      |              ^
answer.code:62:6: error: redefinition of ‘void solve()’
   62 | void solve(){
      |      ^~~~~
answer.code:17:6: note: ‘void solve()’ previously defined here
   17 | void solve(){
      |      ^~~~~
answer.code:81:5: error: redefinition of ‘int main()’
   81 | int main() {
      |     ^~~~
answer.code:36:5: note: ‘int main()’ previously defined here
   36 | int main() {
      |     ^~~~