| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 335807 | Mo_TOI_I_am_Garbage | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 9073 ms | 3688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bubblesort2.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> pos;
int bit[500050];
void add(int x, int d)
{
while(x)
{
bit[x] += d;
x -= x & -x;
}
}
int search(int x)
{
int res = 0;
while(x <= pos.size())
{
res += bit[x];
x += x & -x;
}
return res;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V)
{
for(int x : A) pos.push_back(x);
for(int x : V) pos.push_back(x);
pos.push_back(-1e9);
sort(pos.begin(), pos.end());
pos.resize(unique(pos.begin(), pos.end()) - pos.begin());
vector<int> res;
for(int i=0; i < (int)X.size(); i ++)
{
memset(bit, 0, sizeof(bit));
int ans = 0;
A[X[i]] = V[i];
for(int j=0; j < (int)A.size(); j ++)
{
int ind = lower_bound(pos.begin(), pos.end(), A[j]) - pos.begin();
ans = max(ans, search(ind + 1));
add(ind, 1);
}
res.push_back(ans);
}
return res;
}
// int readInt(){
// int i;
// if(scanf("%d",&i)!=1){
// fprintf(stderr,"Error while reading input\n");
// exit(1);
// }
// return i;
// }
// int main(){
// int N,Q;
// N=readInt();
// Q=readInt();
// std::vector<int> A(N);
// for(int i=0;i<N;i++)
// A[i]=readInt();
// std::vector<int> X(Q),V(Q);
// for(int j=0;j<Q;j++){
// X[j]=readInt();
// V[j]=readInt();
// }
// std::vector<int> res=countScans(A,X,V);
// for(int j=0;j<int(res.size());j++)
// printf("%d\n",res[j]);
// }컴파일 시 표준 에러 (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... | ||||
