# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83430 | 2018-11-07T14:43:41 Z | tjdgus4384 | 곡선 자르기 (KOI17_cut) | C++14 | 2 ms | 632 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; 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 | 380 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 424 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 500 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 632 KB | Output is correct |
13 | Correct | 2 ms | 632 KB | Output is correct |
14 | Correct | 2 ms | 632 KB | Output is correct |
15 | Incorrect | 2 ms | 632 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 424 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 500 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 632 KB | Output is correct |
13 | Correct | 2 ms | 632 KB | Output is correct |
14 | Correct | 2 ms | 632 KB | Output is correct |
15 | Incorrect | 2 ms | 632 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 424 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 500 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 632 KB | Output is correct |
13 | Correct | 2 ms | 632 KB | Output is correct |
14 | Correct | 2 ms | 632 KB | Output is correct |
15 | Incorrect | 2 ms | 632 KB | Output isn't correct |