| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 741145 | speedyArda | 새 집 (APIO18_new_home) | C++14 | 375 ms | 70060 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1e5+5;
int type[MAXN];
vector< pair< pair<int, int>, pair<int, int> > > stores;
vector< pair<int, pair<int, int> > > queries;
vector<int> ans(MAXN);
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k, q;
cin >> n >> k >> q;
for(int i = 0; i < n; i++)
{
int x, t, a, b;
cin >> x >> t >> a >> b;
stores.push_back({{a, 0}, {x, t}});
stores.push_back({{b + 1, 1}, {x, t}});
}
for(int i = 0; i < q; i++)
{
int l, y;
cin >> l >> y;
queries.push_back({y, {i, l}});
}
sort(queries.begin(), queries.end());
sort(stores.begin(), stores.end());
int curr = 0, use = 0;
multiset<int> elems;
for(int i = 0; i < q; i++)
{
while(curr < stores.size() && stores[curr].first.first <= queries[i].first)
{
if(stores[curr].first.second == 0)
{
type[stores[curr].second.second]++;
if(type[stores[curr].second.second] == 1)
use++;
elems.insert(stores[curr].second.first);
} else
{
type[stores[curr].second.second]--;
if(type[stores[curr].second.second] == 0)
use--;
elems.erase(elems.find(stores[curr].second.first));
}
curr++;
}
if(use != k)
{
ans[queries[i].second.first] = -1;
} else
{
auto it = elems.end();
it--;
int left = abs(queries[i].second.second - (*elems.begin())), right = abs(queries[i].second.second - (*it));
ans[queries[i].second.first] = max(left, right);
}
}
for(int i = 0; i < q; i++)
cout << ans[i] << "\n";
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
