编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22960 | #1119. Rhodoks的2-sum问题 | Compile Error | 0 | 0 ms | 0 K | C++ / 936 B | 机类910-尚锦奥 | 2020-02-15 18:16:39 |
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#define lson node << 1
#define rson node << 1 | 1
using namespace std;
#define ll long long
const ll maxn = 5e5 + 10;
ll read() {
char c = getchar();
ll x = 0;
ll flag = 1;
while (c < '0' || c > '9') {
if (c == '-')
flag = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - 48;
c = getchar();
}
x *= flag;
return x;
}
int n, k;
int a[maxn];
int main() {
n = read(), k = read();
for (int i = 1; i <= n; i++) a[i] = read();
sort(a + 1, a + n + 1);
int fg = 0;
for (int i = 1; i <= n - 1; i++) {
int l = i + 1, r = n;
int ans = n;
while (l <= r) {
int mid = (l + r) >> 1;
if (a[i] + a[mid] >= k)
ans = mid, r = mid - 1;
else
l = mid + 1;
}
if (a[i] + a[ans] == k)
fg = 1, break;
}
printf(fg == 1 ? "Yes" : "No");
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:52:26: error: expected primary-expression before 'break'
if(a[i]+a[ans]==k)fg=1,break;
^~~~~