# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
70480 | 2018-08-23T04:15:40 Z | KLPP | Bubble Sort 2 (JOI18_bubblesort2) | C++14 | 7435 ms | 525312 KB |
#include "bubblesort2.h" #include<vector> #include<iostream> #include<algorithm> using namespace std; class FT{ int arr[100000]; int n; public: void init(int N){ n=N; for(int i=0;i<=n;i++){ arr[i]=0; } } int query(int prefix){ prefix++; int ans=0; for(;prefix>0;prefix-=(prefix&(-prefix))){ ans+=arr[prefix]; }return ans; } void update(int pos){ pos++; for(;pos<=n;pos+=(pos&(-pos))){ arr[pos]++; } } void print(){ for(int i=0;i<=n;i++){ cout<<arr[i]<<" "; }cout<<endl; } }; int compute(vector<int> v){ int n=v.size(); FT *A=new FT(); A->init(n); pair<int,int> arr[n]; for(int i=0;i<n;i++){ arr[i]=pair<int,int>(v[i],i); }sort(arr,arr+n); int prev=n-1; int ans=0; for(int i=n-1;i>-1;i--){ if(i==0 || arr[i-1]!=arr[i]){ for(int j=prev;j>=i;j--){ ans=max(ans,A->query(arr[j].second)); } for(int j=prev;j>=i;j--){ A->update(arr[j].second); } //A->print(); prev=i-1; } } return ans; } std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){ vector<int> ans; for(int i=0;i<X.size();i++){ A[X[i]]=V[i]; ans.push_back(compute(A)); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 195 ms | 226360 KB | Output is correct |
2 | Correct | 347 ms | 368916 KB | Output is correct |
3 | Runtime error | 1045 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 195 ms | 226360 KB | Output is correct |
2 | Correct | 347 ms | 368916 KB | Output is correct |
3 | Runtime error | 1045 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 7435 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 195 ms | 226360 KB | Output is correct |
2 | Correct | 347 ms | 368916 KB | Output is correct |
3 | Runtime error | 1045 ms | 525312 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Halted | 0 ms | 0 KB | - |