| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 513152 | 79brue | Worst Reporter 2 (JOI16_worst_reporter2) | C++14 | 2087 ms | 13664 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
Compilation message (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... | ||||
