QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783774 | #3573. Joint Venture | SGColin# | 100 ✓ | 1792ms | 11424kb | C++17 | 1.0kb | 2024-11-26 11:44:29 | 2024-11-26 11:44:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define eb emplace_back
#define pb push_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
inline int rd() {
int x = 0;
bool f = false;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
int L, n;
void work() {
L *= 10'000'000;
vector<int> num;
rep(i, 1, n) {int x; cin >> x; num.eb(x);}
sort(all(num));
int ptr = 0;
per(i, n - 1, 1) {
while (ptr < n && num[ptr] + num[i] < L) ++ptr;
if (ptr >= i) break;
if (num[ptr] + num[i] == L) {
printf("yes %d %d\n", num[ptr], num[i]);
return;
}
}
puts("danger");
}
int main() {
while (cin >> L >> n) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 100
Accepted
time: 1792ms
memory: 11424kb
input:
1 4 9999998 1 2 9999999 1 0 1 1 5 1 1 10000000 1 1 5000000 1 2 9999997 3 1 2 9999998 3 1 3 2 9999997 5000000 1 3 4 9999996 5000000 1 3 5000000 5000000 5000000 1 3 5000000 5000000 2345 1 3 5000000 3455 5000000 1 3 6000000 5000000 5000000 1 4 2000000 3000000 5000000 6000000 1 4 2000000 4000000 5000000...
output:
yes 1 9999999 danger danger danger danger yes 3 9999997 danger danger yes 4 9999996 yes 5000000 5000000 yes 5000000 5000000 yes 5000000 5000000 yes 5000000 5000000 danger yes 4000000 6000000 yes 4000000 6000000 yes 5000000 5000000 yes 4999999 5000001 danger danger danger yes 5000000 5000000 yes 1103...
result:
ok 26 lines