# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83428 | 2018-11-07T14:38:46 Z | tjdgus4384 | 곡선 자르기 (KOI17_cut) | C++14 | 6 ms | 2176 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; 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])}); } } if(state) { v.push_back({min(last, x[0]), max(last, x[0])}); } 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 | 376 KB | Output is correct |
3 | Correct | 2 ms | 456 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 3 ms | 480 KB | Output is correct |
7 | Correct | 2 ms | 596 KB | Output is correct |
8 | Correct | 2 ms | 596 KB | Output is correct |
9 | Correct | 2 ms | 596 KB | Output is correct |
10 | Correct | 2 ms | 648 KB | Output is correct |
11 | Correct | 3 ms | 776 KB | Output is correct |
12 | Correct | 2 ms | 800 KB | Output is correct |
13 | Correct | 2 ms | 824 KB | Output is correct |
14 | Correct | 2 ms | 832 KB | Output is correct |
15 | Correct | 2 ms | 940 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 456 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 3 ms | 480 KB | Output is correct |
7 | Correct | 2 ms | 596 KB | Output is correct |
8 | Correct | 2 ms | 596 KB | Output is correct |
9 | Correct | 2 ms | 596 KB | Output is correct |
10 | Correct | 2 ms | 648 KB | Output is correct |
11 | Correct | 3 ms | 776 KB | Output is correct |
12 | Correct | 2 ms | 800 KB | Output is correct |
13 | Correct | 2 ms | 824 KB | Output is correct |
14 | Correct | 2 ms | 832 KB | Output is correct |
15 | Correct | 2 ms | 940 KB | Output is correct |
16 | Correct | 2 ms | 940 KB | Output is correct |
17 | Correct | 3 ms | 940 KB | Output is correct |
18 | Correct | 3 ms | 940 KB | Output is correct |
19 | Correct | 5 ms | 1152 KB | Output is correct |
20 | Correct | 6 ms | 1476 KB | Output is correct |
21 | Correct | 5 ms | 1492 KB | Output is correct |
22 | Correct | 5 ms | 1712 KB | Output is correct |
23 | Correct | 5 ms | 1976 KB | Output is correct |
24 | Incorrect | 5 ms | 2176 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 | 376 KB | Output is correct |
3 | Correct | 2 ms | 456 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 476 KB | Output is correct |
6 | Correct | 3 ms | 480 KB | Output is correct |
7 | Correct | 2 ms | 596 KB | Output is correct |
8 | Correct | 2 ms | 596 KB | Output is correct |
9 | Correct | 2 ms | 596 KB | Output is correct |
10 | Correct | 2 ms | 648 KB | Output is correct |
11 | Correct | 3 ms | 776 KB | Output is correct |
12 | Correct | 2 ms | 800 KB | Output is correct |
13 | Correct | 2 ms | 824 KB | Output is correct |
14 | Correct | 2 ms | 832 KB | Output is correct |
15 | Correct | 2 ms | 940 KB | Output is correct |
16 | Correct | 2 ms | 940 KB | Output is correct |
17 | Correct | 3 ms | 940 KB | Output is correct |
18 | Correct | 3 ms | 940 KB | Output is correct |
19 | Correct | 5 ms | 1152 KB | Output is correct |
20 | Correct | 6 ms | 1476 KB | Output is correct |
21 | Correct | 5 ms | 1492 KB | Output is correct |
22 | Correct | 5 ms | 1712 KB | Output is correct |
23 | Correct | 5 ms | 1976 KB | Output is correct |
24 | Incorrect | 5 ms | 2176 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |