답안 #915064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915064 2024-01-23T09:34:18 Z manizare Bubble Sort 2 (JOI18_bubblesort2) C++14
38 / 100
9000 ms 1884 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define ld long double
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
using namespace std ;   
const int maxn = 1e6 + 10 , inf= 2e9 , mod = 1e9 + 7 , sq = 360 ,MX = 20000 ;
struct fenwick{
    int fen[2*MX] ;
    void upd(int x ,int w){
        x++;
        while(x <= MX){
            fen[x]+=w;
            x+=x&-x; 
        }
    }
    int que(int x){
        x++;int ans =0 ;
        while(x){   
            ans+=fen[x];
            x-=x&-x;
        }
        return ans ;
    }
}f;
 
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) {
    int n = sz(A) , q =sz(X) ;     
    vector <int> res(q) , cm;
    rep(i , 0 , n-1)cm.pb(A[i]);
    rep(i , 0 ,q-1)cm.pb(V[i]) ;
    sort(all(cm)) ;
    cm.resize(unique(all(cm))-cm.begin()) ;
    rep(i , 0 , n-1){
        A[i] = lower_bound(all(cm) , A[i]) -cm.begin() ;
    }
    rep(i , 0 , q-1){
        A[X[i]] = lower_bound(all(cm),V[i])-cm.begin() ;
        int ans =0 ;
        rep(j , 0 , n-1){
            ans = max(ans , j-f.que(A[j])) ;
            f.upd(A[j] , 1);
        }
        rep(i , 0 , sz(cm))f.fen[i]=0;
        res[i]=ans;
    }
    return res; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 10 ms 348 KB Output is correct
3 Correct 67 ms 344 KB Output is correct
4 Correct 68 ms 348 KB Output is correct
5 Correct 67 ms 344 KB Output is correct
6 Correct 61 ms 348 KB Output is correct
7 Correct 64 ms 568 KB Output is correct
8 Correct 73 ms 572 KB Output is correct
9 Correct 68 ms 348 KB Output is correct
10 Correct 54 ms 564 KB Output is correct
11 Correct 53 ms 344 KB Output is correct
12 Correct 58 ms 456 KB Output is correct
13 Correct 52 ms 344 KB Output is correct
14 Correct 52 ms 600 KB Output is correct
15 Correct 55 ms 448 KB Output is correct
16 Correct 53 ms 348 KB Output is correct
17 Correct 52 ms 344 KB Output is correct
18 Correct 52 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 10 ms 348 KB Output is correct
3 Correct 67 ms 344 KB Output is correct
4 Correct 68 ms 348 KB Output is correct
5 Correct 67 ms 344 KB Output is correct
6 Correct 61 ms 348 KB Output is correct
7 Correct 64 ms 568 KB Output is correct
8 Correct 73 ms 572 KB Output is correct
9 Correct 68 ms 348 KB Output is correct
10 Correct 54 ms 564 KB Output is correct
11 Correct 53 ms 344 KB Output is correct
12 Correct 58 ms 456 KB Output is correct
13 Correct 52 ms 344 KB Output is correct
14 Correct 52 ms 600 KB Output is correct
15 Correct 55 ms 448 KB Output is correct
16 Correct 53 ms 348 KB Output is correct
17 Correct 52 ms 344 KB Output is correct
18 Correct 52 ms 348 KB Output is correct
19 Correct 1127 ms 960 KB Output is correct
20 Correct 1442 ms 1020 KB Output is correct
21 Correct 1401 ms 1016 KB Output is correct
22 Correct 1449 ms 1016 KB Output is correct
23 Correct 1080 ms 980 KB Output is correct
24 Correct 1067 ms 984 KB Output is correct
25 Correct 1070 ms 976 KB Output is correct
26 Correct 1083 ms 1112 KB Output is correct
27 Correct 1078 ms 972 KB Output is correct
28 Correct 1075 ms 988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1298 ms 1036 KB Output is correct
2 Execution timed out 9023 ms 1884 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 10 ms 348 KB Output is correct
3 Correct 67 ms 344 KB Output is correct
4 Correct 68 ms 348 KB Output is correct
5 Correct 67 ms 344 KB Output is correct
6 Correct 61 ms 348 KB Output is correct
7 Correct 64 ms 568 KB Output is correct
8 Correct 73 ms 572 KB Output is correct
9 Correct 68 ms 348 KB Output is correct
10 Correct 54 ms 564 KB Output is correct
11 Correct 53 ms 344 KB Output is correct
12 Correct 58 ms 456 KB Output is correct
13 Correct 52 ms 344 KB Output is correct
14 Correct 52 ms 600 KB Output is correct
15 Correct 55 ms 448 KB Output is correct
16 Correct 53 ms 348 KB Output is correct
17 Correct 52 ms 344 KB Output is correct
18 Correct 52 ms 348 KB Output is correct
19 Correct 1127 ms 960 KB Output is correct
20 Correct 1442 ms 1020 KB Output is correct
21 Correct 1401 ms 1016 KB Output is correct
22 Correct 1449 ms 1016 KB Output is correct
23 Correct 1080 ms 980 KB Output is correct
24 Correct 1067 ms 984 KB Output is correct
25 Correct 1070 ms 976 KB Output is correct
26 Correct 1083 ms 1112 KB Output is correct
27 Correct 1078 ms 972 KB Output is correct
28 Correct 1075 ms 988 KB Output is correct
29 Correct 1298 ms 1036 KB Output is correct
30 Execution timed out 9023 ms 1884 KB Time limit exceeded
31 Halted 0 ms 0 KB -