# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
690851 | ismayil | Fountain (eJOI20_fountain) | C++17 | 281 ms | 22104 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX = 1e5 + 5, LOG = 20, INF = 2e9;
int up[MAX][LOG], sum[MAX][LOG], D[MAX];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, q;
cin>>n>>q;
for (int i = 1; i <= n; i++) cin>>D[i]>>sum[i][0];
D[n + 1] = INF;
sum[n + 1][0] = INF;
up[n + 1][0] = n + 1;
stack<int> s;
s.push(n + 1);
for (int i = n; i >= 1; i--)
{
while(D[s.top()] <= D[i]) s.pop();
up[i][0] = s.top();
s.push(i);
}
for (int i = 1; i < LOG; i++)
{
for (int j = 1; j <= n; j++)
{
up[j][i] = up[up[j][i - 1]][i - 1];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |