| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 31149 | gs14004 | Arranging Tickets (JOI17_arranging_tickets) | C++14 | 879 ms | 4768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
struct intv{ int s, e, x; }a[100005];
int n, m;
int dx[200005], b[200005];
struct seg{
int tree[3005];
void init(){ memset(tree, 0, sizeof(tree)); }
void add(int x, int v){
while(x <= n){
tree[x] += v;
x += x & -x;
}
}
int query(int x){
int ret = 0;
while(x){
ret += tree[x];
x -= x & -x;
}
return ret;
}
}seg;
int solve(int x){
int pnt = 0;
priority_queue<int> pq;
seg.init();
for(int i=1; i<n; i++) b[i] = max(dx[i] - x, 0);
for(int i=1; i<n; i++){
seg.add(i, b[i] - b[i-1]);
}
for(int i=1; i<n; i++){
while(pnt < m && a[pnt].s <= i){
pq.push(a[pnt++].e);
}
while(seg.query(i) > 0 && !pq.empty()){
auto l = pq.top();
pq.pop();
if(l <= i) continue;
seg.add(i, -2);
seg.add(l, 2);
x++;
}
if(seg.query(i) > 0) return 1e9;
}
return x;
}
int main(){
scanf("%d %d",&n,&m);
for(int i=0; i<m; i++){
scanf("%d %d %d",&a[i].s,&a[i].e,&a[i].x);
assert(a[i].x == 1);
if(a[i].s > a[i].e) swap(a[i].s, a[i].e);
}
sort(a, a+m, [&](const intv &a, const intv &b){
return a.s < b.s;
});
for(int i=0; i<m; i++){
dx[a[i].s]++;
dx[a[i].e]--;
}
for(int i=1; i<=n; i++) dx[i] += dx[i-1];
int ans = 1e9;
for(int i=-m; i<=m; i++){
ans = min(ans, solve(i));
}
printf("%d\n", ans);
}
컴파일 시 표준 에러 (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... | ||||
