QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#90536 | #5251. Constellations | SolitaryDream# | WA | 1ms | 9808kb | C++20 | 1.6kb | 2023-03-23 15:23:59 | 2023-03-23 15:24:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
const int N = 2e5 + 10;
int n, m, ans[N];
vector<pii> que[N];
struct Point {
int x, y;
};
Point p[N];
Point operator+(Point u, Point v) { return {u.x + v.x, u.y + v.y}; }
Point operator-(Point u, Point v) { return {u.x - v.x, u.y - v.y}; }
int Det(Point u, Point v) { return u.x * v.y - u.y * v.x; }
signed main() {
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%lld", &p[i].y);
p[i].y += p[i - 1].y;
p[i].x = i;
}
for (int i = 1, x, y; i <= m; ++i) {
scanf("%lld%lld", &x, &y);
que[x - 1].push_back(pii(x + y - 1, i));
}
vector<int> conv;
for (int i = n; ~i; --i) {
static vector<int> sp; sp.clear();
while (conv.size() >= 2 && Det(p[conv.size() - 2] - p[i], p[conv.size() - 1] - p[i]) <= 0) {
sp.push_back(conv.back());
conv.pop_back();
}
if (conv.size()) sp.push_back(conv.back());
conv.push_back(i);
sort(que[i].begin(), que[i].end());
int pt = 0;
for (auto [y, id] : que[i]) {
while (pt + 1 < (int)sp.size() && sp[pt] <= y) ++pt;
Point delta = p[sp[pt]] - p[i];
printf("[%lld %lld] : %lld %lld\n", i + 1, y, delta.y, delta.x);
if (delta.y < 0) ans[id] = -1;
else ans[id] = delta.y / delta.x;
}
}
for (int i = 1; i <= m; ++i) {
if (ans[i] < 0) puts("stay with parents");
else printf("%lld\n", ans[i]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 9808kb
input:
2 0 0 1 0
output:
result:
wrong answer 1st lines differ - expected: '2', found: ''