| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 30067 | gs14004 | 무제 (POI11_rot) | C++14 | 169 ms | 8408 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<lint, lint> pi;
const int MAXN = 200005;
int a[MAXN], n, cnt;
struct bit{
int tree[MAXN];
void add(int x, int v){
while(x <= n){
tree[x] += v;
x += x & -x;
}
}
int query(int x){
int ret = 0;
while(x) ret += tree[x], x -= x & -x;
return ret;
}
}bit;
lint solve(int s, int m, int e){
lint ans = 0;
if(e - m > m - s){
for(int j=s; j<m; j++) bit.add(a[j], -1);
for(int j=s; j<m; j++) ans += bit.query(a[j] - 1);
for(int j=s; j<m; j++) bit.add(a[j], 1);
}
else{
for(int j=m; j<e; j++) bit.add(a[j], -1);
for(int j=m; j<e; j++) ans += m - s - bit.query(a[j]);
for(int j=m; j<e; j++) bit.add(a[j], 1);
}
return ans;
}
lint solve(){
int x;
scanf("%d",&x);
lint ans = 0;
if(x == 0){
int s = cnt;
ans += solve();
int m = cnt;
ans += solve();
int e = cnt;
lint tmp = solve(s, m, e);
ans += min(tmp, 1ll * (e - m) * (m - s) - tmp);
}
else{
bit.add(x, 1);
a[cnt++] = x;
}
return ans;
}
int main(){
scanf("%d",&n);
printf("%lld\n", solve());
}
컴파일 시 표준 에러 (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... | ||||
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
