QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#672801 | #2386. Fishermen | Yarema# | WA | 0ms | 3748kb | C++14 | 1.4kb | 2024-10-24 19:08:53 | 2024-10-24 19:08:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
struct fish
{
int x, y, i;
bool operator<(const fish& f) const
{
return MP(x - y, i) < MP(f.x - f.y, f.i);
}
};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, l;
cin >> n >> m >> l;
vector<PII> f(n);
FOR (i, 0, n)
cin >> f[i].F >> f[i].S;
sort(ALL(f), [](PII a, PII b)
{
return a.F + a.S < b.F + b.S;
});
set<fish> s;
VI a(m);
FOR (i, 0, m)
cin >> a[i];
VI idx(m);
iota(ALL(idx), 0);
sort(ALL(idx), [&a](int i, int j)
{
return a[i] < a[j];
});
VI ans(m);
int j = 0;
for (auto i : idx)
{
//cerr << i << ' ' << j << ' ' << f[j].F + f[j].S << ' ' << a[i] + l << '\n';
while (j < n && f[j].F + f[j].S <= a[i] + l)
{
s.insert({f[j].F, f[j].S, j});
j++;
}
while (!s.empty())
{
fish p = *s.begin();
if (p.x - p.y < a[i] - l)
s.erase(s.begin());
else
break;
}
ans[i] = SZ(s);
}
FOR (i, 0, m)
{
if (i)
cout << ' ';
cout << ans[i];
}
cout << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3748kb
input:
8 4 4 7 2 3 3 4 5 5 1 2 2 1 4 8 4 9 4 6 1 4 9
output:
2 2 3 2
result:
wrong answer 1st lines differ - expected: '2', found: '2 2 3 2'