# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
513152 | 79brue | Worst Reporter 2 (JOI16_worst_reporter2) | C++14 | 2087 ms | 13664 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct dat{
int x, y; bool d; /// 0: 진입
dat(){}
dat(int x, int y, bool d): x(x), y(y), d(d){}
bool operator<(const dat &r)const{
if(y != r.y) return y < r.y;
return d < r.d;
}
};
int n;
vector<dat> vec;
int cnt[200002];
int ans;
int main(){
scanf("%d", &n);
for(int i=1; i<=n; i++){
int x, y;
scanf("%d %d", &x, &y);
vec.push_back(dat(x, y, 0));
}
for(int i=1; i<=n; i++){
int x, y;
scanf("%d %d", &x, &y);
vec.push_back(dat(x, y, 1));
}
sort(vec.begin(), vec.end());
for(int i=0; i<n+n; i++){
if(vec[i].d == 0){
cnt[vec[i].x]++;
continue;
}
if(cnt[vec[i].x]){
cnt[vec[i].x]--;
continue;
}
ans++;
vector<int> problem (n+5, 1e9);
vector<int> sum (n+5, 0);
for(int j=1; j<=n; j++) sum[j] = cnt[j] - 1;
for(int j=i; j<n+n; j++){
if(vec[j].d == 0) sum[vec[j].x]++;
else if(sum[vec[j].x]) sum[vec[j].x]--;
else problem[vec[j].x] = min(problem[vec[j].x], j);
}
int key = 0, val = -1;
for(int j=1; j<=n; j++) if(cnt[j] && problem[j] > val) val = problem[j], key = j;
cnt[key]--;
}
printf("%d", 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... |