# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
827584 | 2023-08-16T15:00:43 Z | tolbi | Roller Coaster Railroad (IOI16_railroad) | C++17 | 69 ms | 9680 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #include "railroad.h" mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); long long plan_roller_coaster(vector<int> s, vector<int> t) { vector<pair<int,pair<int,int>>> arr; for (int i = 0; i < s.size(); i++){ if (s[i]==t[i]) continue; int c = 1; if (s[i]>=t[i]){ c=-1; } arr.push_back({min(s[i],t[i]),{c,1}}); arr.push_back({max(s[i],t[i])+1,{-c,0}}); } sort(arr.begin(), arr.end()); ll crr = -1; ll crr2 = 0; int n = arr.size(); ll ans = 0; for (int i = 0; i < n; i++){ if (i<n-1 && arr[i].first==arr[i+1].first){ crr+=arr[i].second.first; crr2+=arr[i].second.second; continue; } crr+=arr[i].second.first; crr2+=arr[i].second.second; if (crr>0){ ans+=crr*(arr[i+1].first-arr[i].first); } if (crr2==0){ ans+=arr[i+1].first-arr[i].first; } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n = 2 |
2 | Correct | 0 ms | 212 KB | n = 2 |
3 | Correct | 1 ms | 212 KB | n = 2 |
4 | Correct | 0 ms | 212 KB | n = 2 |
5 | Correct | 0 ms | 212 KB | n = 2 |
6 | Incorrect | 0 ms | 212 KB | answer is not correct: 523688154 instead of 523688153 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n = 2 |
2 | Correct | 0 ms | 212 KB | n = 2 |
3 | Correct | 1 ms | 212 KB | n = 2 |
4 | Correct | 0 ms | 212 KB | n = 2 |
5 | Correct | 0 ms | 212 KB | n = 2 |
6 | Incorrect | 0 ms | 212 KB | answer is not correct: 523688154 instead of 523688153 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 9664 KB | n = 199999 |
2 | Correct | 69 ms | 9660 KB | n = 199991 |
3 | Correct | 69 ms | 9652 KB | n = 199993 |
4 | Correct | 51 ms | 8900 KB | n = 152076 |
5 | Correct | 36 ms | 4984 KB | n = 93249 |
6 | Correct | 66 ms | 9660 KB | n = 199910 |
7 | Correct | 65 ms | 9680 KB | n = 199999 |
8 | Correct | 64 ms | 9664 KB | n = 199997 |
9 | Correct | 62 ms | 9176 KB | n = 171294 |
10 | Correct | 49 ms | 8764 KB | n = 140872 |
11 | Incorrect | 65 ms | 9668 KB | answer is not correct: 0 instead of 1 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | n = 2 |
2 | Correct | 0 ms | 212 KB | n = 2 |
3 | Correct | 1 ms | 212 KB | n = 2 |
4 | Correct | 0 ms | 212 KB | n = 2 |
5 | Correct | 0 ms | 212 KB | n = 2 |
6 | Incorrect | 0 ms | 212 KB | answer is not correct: 523688154 instead of 523688153 |
7 | Halted | 0 ms | 0 KB | - |