编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3430 #1011. 小田的存钱罐 Compile Error 0 0 ms 0 K C++ 17 / 751 B t330026124 2023-11-25 15:09:54
显示原始代码
#include <bits/stdc++.h>
using namespace std;
int sta[1000000000];
int main() {
    int top = 0;
    int q, choose;
    cin >> q;
    for (int i = 1; i <= q; i++) {
        cin >> choose;
        if (choose == 1) {
            int x;
            cin >> x;
            top++;
            sta[top] = x;
        }
        if (choose == 2) {
            int c, x;
            cin >> x >> c;
            for (int j = 1; j <= top; j++) {
                if (sta[j] == x) {
                    for (int k = j; k < top; k++) {
                        sta[k] = sta[k + 1];
                    }
                    top--;
                    j--;
                }
            }
        }
        if (choose == 3) {
            int max = 0, min = 10000000000;
            for (int j = 1; j <= top; j++) {
                if (sta[j] > max) {
                    max = sta[j];
                }
                if (sta[j] < min) {
                    min = sta[j];
                }
            }
            printf("%d\n", max - min);
        }
    }
    return 0;
}

编译信息

/sandbox/1/a.cpp:3:5: error: size '4000000000' of array 'sta' exceeds maximum object size '2147483647'
    3 | int sta[1000000000];
      |     ^~~
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:14:4: error: 'sta' was not declared in this scope; did you mean 'std'?
   14 |    sta[top] = x;
      |    ^~~
      |    std
/sandbox/1/a.cpp:20:10: error: 'sta' was not declared in this scope; did you mean 'std'?
   20 |     if ( sta[j] == x ){
      |          ^~~
      |          std
/sandbox/1/a.cpp:30:23: warning: overflow in conversion from 'long long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   30 |    int max = 0, min = 10000000000;
      |                       ^~~~~~~~~~~
/sandbox/1/a.cpp:32:10: error: 'sta' was not declared in this scope; did you mean 'std'?
   32 |     if ( sta[j] > max ){
      |          ^~~
      |          std
/sandbox/1/a.cpp:35:10: error: 'sta' was not declared in this scope; did you mean 'std'?
   35 |     if ( sta[j] < min ){
      |          ^~~
      |          std