# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
744228 |
2023-05-18T09:47:23 Z |
b00norp |
Boat (APIO16_boat) |
C++14 |
|
2000 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e18, N = 1e6 + 4;
int seg[N * 4];
void Update(int l, int r, int pos, int qpos, int qval)
{
if(l == r)
{
seg[pos] = qval;
return;
}
int mid = (l + r) >> 1;
if(qpos <= mid)
{
Update(l, mid, pos * 2, qpos, qval);
}
else
{
Update(mid + 1, r, pos * 2 + 1, qpos, qval);
}
seg[pos] = seg[pos * 2] + seg[pos * 2 + 1];
}
int Query(int l, int r, int pos, int ql, int qr)
{
if(ql <= l && r <= qr)
{
return seg[pos];
}
if(ql > r || l > qr)
{
return 0;
}
int mid = (l + r) >> 1;
return Query(l, mid, pos * 2, ql, qr) + Query(mid + 1, r, pos * 2 + 1, ql, qr);
}
void Solve()
{
int n;
cin >> n;
vector<pair<int, int> > a(n);
for(int i = 0; i < n; i++)
{
cin >> a[i].first >> a[i].second;
}
Update(0, N, 1, 0, 1);
for(int i = 0; i < n; i++)
{
for(int j = a[i].second; j >= a[i].first; j--)
{
int val = Query(0, N, 1, 0, j - 1);
Update(0, N, 1, j, val);
}
}
cout << Query(0, N, 1, 0, N) << "\n";
}
int32_t main()
{
auto begin = std::chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++)
{
//cout << "Case #" << i << ": ";
Solve();
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
//cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2031 ms |
340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |