# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83434 | tjdgus4384 | 곡선 자르기 (KOI17_cut) | C++14 | 37 ms | 5288 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<cstdio>
#include<vector>
#include<algorithm>
int x[100001], y[100001];
using namespace std;
vector<pair<int, int> > v;
int main()
{
int n;
scanf("%d", &n);
for(int i = 0;i < n;i++)
{
scanf("%d %d", &x[i], &y[i]);
}
int state = 0, last, st = x[0];
bool change = false;
for(int i = 1;i < n;i++)
{
if(y[i - 1] < 0 && y[i] > 0) {last = x[i];state = 1;}
else if(state && y[i - 1] > 0 && y[i] < 0)
{
state = 0;
v.push_back({min(last, x[i]), max(last, x[i])});
}
else if(y[i - 1] > 0 && y[i] < 0) {st = x[i]; change = true;}
}
if(state)
{
v.push_back({min(last, st), max(last, st)});
}
else if(change)
{
v.push_back({min(x[0], st), max(x[0], st)});
}
sort(v.begin(), v.end());
int ans1 = 0, ans2 = 0;
int maxx = -2e9;
for(int i = 0;i < v.size();i++)
{
if(maxx < v[i].first) ans1++;
maxx = max(maxx, v[i].second);
if(i == v.size() - 1 || v[i + 1].first > v[i].second) ans2++;
}
printf("%d %d", ans1, ans2);
return 0;
}
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... |