QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#300806#6434. Paimon SortingJooDdaeWA 1ms3512kbC++20985b2024-01-08 20:34:532024-01-08 20:34:53

Judging History

你现在查看的是最新测评结果

  • [2024-01-08 20:34:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3512kb
  • [2024-01-08 20:34:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// find_by_order(K) = K번째 수(0 base), order_of_key(K) = K보다 작은 수의 개수, less -> less_equal to multiset, change null_type to map
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pbds = tree <int, int, less<>, rb_tree_tag, tree_order_statistics_node_update>;

int n, a[100100];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int tc; cin >> tc;
    while(tc--) {
        cin >> n;
        for(int i=1;i<=n;i++) cin >> a[i];
        pbds mp;

        ll ans = 0;
        for(int i=1;i<=n;i++) {
            if(a[i] > a[1]) {
                if(!--mp[-a[1]]) mp.erase(-a[1]);
                swap(a[i], a[1]), ans++;
                mp[-a[1]]++;
            }
            ans += mp.order_of_key(-a[i]);
            mp[-a[i]]++;
            cout << ans << " ";
        }
        cout << "\n";
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3512kb

input:

3
5
2 3 2 1 5
3
1 2 3
1
1

output:

0 2 3 5 7 
0 2 4 
0 

result:

wrong answer 1st lines differ - expected: '0 2 3 5 7', found: '0 2 3 5 7 '