QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#876558#2325. CornspanzyCompile Error//C++20371b2025-01-31 00:00:282025-01-31 00:00:28

Judging History

This is the latest submission verdict.

  • [2025-01-31 00:00:28]
  • Judged
  • [2025-01-31 00:00:28]
  • Submitted

answer

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

int main() {
    int n, w;	cin >> n >> W;
    bitset<2e5+1> dp;

    dp[0] = 1;
    for (int i = 1; i <= n; i ++) {
        int x; cin >> x;
        dp |= (dp << x);
    }

    for (int i = 2e5; i >= 0; i --) {
        if (dp[i]) {
            return cout << i << "\n",0;
        }
    }

    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:5:29: error: ‘W’ was not declared in this scope
    5 |     int n, w;   cin >> n >> W;
      |                             ^
answer.code:6:15: error: conversion from ‘double’ to ‘long unsigned int’ in a converted constant expression
    6 |     bitset<2e5+1> dp;
      |            ~~~^~
answer.code:6:15: error: could not convert ‘(2.0e+5 + (double)1)’ from ‘double’ to ‘long unsigned int’
    6 |     bitset<2e5+1> dp;
      |            ~~~^~
      |               |
      |               double
answer.code:8:7: error: invalid types ‘int[int]’ for array subscript
    8 |     dp[0] = 1;
      |       ^
answer.code:15:15: error: invalid types ‘int[int]’ for array subscript
   15 |         if (dp[i]) {
      |               ^