# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
390495 | Keshi | 고대 책들 (IOI17_books) | C++17 | 2076 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//In the name of God
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll a[maxn], b[maxn];
long long minimum_walk(vector<int> p, int s){
ll n = Sz(p);
for(ll i = 0; i < n; i++){
if(p[i] > i){
a[i]++;
a[p[i]]--;
}
else{
b[p[i]]++;
b[i]--;
}
}
for(ll i = 1; i < n; i++){
a[i] += a[i - 1];
b[i] += b[i - 1];
}
ll r = n;
while(r && p[r - 1] == r - 1) r--;
ll l = 0;
while(l < n && p[l] == l) l;
l = min(l, ll(s));
r = max(r, s + 1ll);
ll ans = 0;
for(ll i = l; i < r - 1; i++){
ans += max(1ll, max(a[i], b[i]));
}
return ans * 2;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |