编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#21966 #1119. Rhodoks的2-sum问题 Compile Error 0 0 ms 0 K C++ 11 / 545 B Diorvh 2020-02-11 15:13:46
显示原始代码
#include <bits/stdc++.h>
using namespace std;
const int M = 5e5 + 20;
int a[M];
char mp[3000000000];
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]), ++mp[a[i]];
        if (k - a[i] == a[i]) {
            if (mp[k - a[i]] >= 2) {
                printf("Yes\n");
                return 0;
            }
        } else {
            if (mp[k - a[i]] >= 1) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

编译信息

/sandbox/1/a.cpp:5:19: error: size of array 'mp' is negative
 char mp[3000000000];
                   ^
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
/sandbox/1/a.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]),++mp[a[i]];
         ~~~~~^~~~~~~~~~~~