# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83431 | 2018-11-07T14:45:20 Z | tjdgus4384 | 곡선 자르기 (KOI17_cut) | C++14 | 5 ms | 660 KB |
#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]; 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]; } if(state) { v.push_back({min(last, st), max(last, 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 520 KB | Output is correct |
3 | Correct | 2 ms | 520 KB | Output is correct |
4 | Correct | 2 ms | 612 KB | Output is correct |
5 | Correct | 3 ms | 612 KB | Output is correct |
6 | Correct | 2 ms | 612 KB | Output is correct |
7 | Correct | 2 ms | 612 KB | Output is correct |
8 | Correct | 2 ms | 612 KB | Output is correct |
9 | Correct | 2 ms | 612 KB | Output is correct |
10 | Correct | 2 ms | 612 KB | Output is correct |
11 | Correct | 2 ms | 612 KB | Output is correct |
12 | Correct | 2 ms | 612 KB | Output is correct |
13 | Correct | 3 ms | 624 KB | Output is correct |
14 | Correct | 2 ms | 624 KB | Output is correct |
15 | Correct | 3 ms | 624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 520 KB | Output is correct |
3 | Correct | 2 ms | 520 KB | Output is correct |
4 | Correct | 2 ms | 612 KB | Output is correct |
5 | Correct | 3 ms | 612 KB | Output is correct |
6 | Correct | 2 ms | 612 KB | Output is correct |
7 | Correct | 2 ms | 612 KB | Output is correct |
8 | Correct | 2 ms | 612 KB | Output is correct |
9 | Correct | 2 ms | 612 KB | Output is correct |
10 | Correct | 2 ms | 612 KB | Output is correct |
11 | Correct | 2 ms | 612 KB | Output is correct |
12 | Correct | 2 ms | 612 KB | Output is correct |
13 | Correct | 3 ms | 624 KB | Output is correct |
14 | Correct | 2 ms | 624 KB | Output is correct |
15 | Correct | 3 ms | 624 KB | Output is correct |
16 | Correct | 2 ms | 624 KB | Output is correct |
17 | Correct | 3 ms | 624 KB | Output is correct |
18 | Correct | 4 ms | 636 KB | Output is correct |
19 | Correct | 5 ms | 660 KB | Output is correct |
20 | Correct | 5 ms | 660 KB | Output is correct |
21 | Correct | 5 ms | 660 KB | Output is correct |
22 | Correct | 5 ms | 660 KB | Output is correct |
23 | Correct | 5 ms | 660 KB | Output is correct |
24 | Incorrect | 5 ms | 660 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 520 KB | Output is correct |
3 | Correct | 2 ms | 520 KB | Output is correct |
4 | Correct | 2 ms | 612 KB | Output is correct |
5 | Correct | 3 ms | 612 KB | Output is correct |
6 | Correct | 2 ms | 612 KB | Output is correct |
7 | Correct | 2 ms | 612 KB | Output is correct |
8 | Correct | 2 ms | 612 KB | Output is correct |
9 | Correct | 2 ms | 612 KB | Output is correct |
10 | Correct | 2 ms | 612 KB | Output is correct |
11 | Correct | 2 ms | 612 KB | Output is correct |
12 | Correct | 2 ms | 612 KB | Output is correct |
13 | Correct | 3 ms | 624 KB | Output is correct |
14 | Correct | 2 ms | 624 KB | Output is correct |
15 | Correct | 3 ms | 624 KB | Output is correct |
16 | Correct | 2 ms | 624 KB | Output is correct |
17 | Correct | 3 ms | 624 KB | Output is correct |
18 | Correct | 4 ms | 636 KB | Output is correct |
19 | Correct | 5 ms | 660 KB | Output is correct |
20 | Correct | 5 ms | 660 KB | Output is correct |
21 | Correct | 5 ms | 660 KB | Output is correct |
22 | Correct | 5 ms | 660 KB | Output is correct |
23 | Correct | 5 ms | 660 KB | Output is correct |
24 | Incorrect | 5 ms | 660 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |