QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#345380 | #3418. Highway of the Future | PetroTarnavskyi# | WA | 23ms | 8552kb | C++20 | 2.2kb | 2024-03-06 21:12:41 | 2024-03-06 21:12:41 |
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 pair<int, int> PII;
typedef double db;
const int MX = 1 << 20;
const int X = 101;
const int Y = 10047;
int n;
int cnt[MX];
VI vecs[X];
vector<PII> vecPairs[X];
int g[MX];
void precalc()
{
FOR(i, 1, X)
FOR(j, 0, Y)
{
int gc = gcd(i, j);
g[Y * i + j] = (Y * i + j) / gc;
}
}
void solve()
{
if (n == 3)
{
cout << 3 << '\n';
return;
}
FOR(i, 0, X)
{
vecs[i].clear();
vecPairs[i].clear();
}
FOR(i, 0, n)
{
int t, v;
cin >> t >> v;
vecs[v].PB(v * t);
}
int ans = 0;
FOR(k, 1, X)
{
sort(ALL(vecs[k]));
for (int j = 0; j < SZ(vecs[k]); )
{
int l = j;
while (l < SZ(vecs[k]) && vecs[k][l] == vecs[k][j])
{
l++;
}
ans = max(ans, l - j);
vecPairs[k].PB({vecs[k][j], l - j});
j = l;
}
}
int used = 0;
const int MAGIC = max(1000, (int)(0.14 * n));
FOR(x1, 1, X)
{
for (auto [y1, c] : vecPairs[x1])
{
used++;
if (used > MAGIC)
break;
int cur = 0;
FOR(x2, x1 + 1, X)
{
auto le = lower_bound(ALL(vecPairs[x2]), MP(y1, 0)),
ri = lower_bound(ALL(vecPairs[x2]), MP(y1 + (x2 - x1) * 100 + 1, 0));
int dx = x2 - x1;
int dx2 = Y * dx - y1;
for (auto it = le; it != ri; it++)
{
int& res = cnt[dx2 + it->F];
res += it->S;
cur = max(cur, res);
}
}
FOR(x2, x1 + 1, X)
{
auto le = lower_bound(ALL(vecPairs[x2]), MP(y1, 0)),
ri = lower_bound(ALL(vecPairs[x2]), MP(y1 + (x2 - x1) * 100 + 1, 0));
int dx = x2 - x1;
int dx2 = Y * dx - y1;
for (auto it = le; it != ri; it++)
{
cnt[dx2 + it->F] -= it->S;
}
}
ans = max(ans, cur + c);
}
}
cout << ans << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
precalc();
while (cin >> n)
{
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 23ms
memory: 8552kb
input:
4 10 10 10 10 15 20 15 20 3 100 100 100 1 100 1
output:
4 3 99
result:
wrong output format Extra information in the output file