QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395210#1363. Bitonic Orderingmegz112233WA 107ms8280kbC++231.0kb2024-04-21 10:53:542024-04-21 10:53:54

Judging History

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

  • [2024-04-21 10:53:54]
  • 评测
  • 测评结果:WA
  • 用时:107ms
  • 内存:8280kb
  • [2024-04-21 10:53:54]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sz(x)  (int)x.size()
#define bigint __int128
#define el '\n'
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5 + 4, M = 1e5 + 10, mod = 998244353;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void acc() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];
    ordered_set<int> l, r;
    for (int i = 0; i < n; i++)r.insert(v[i]);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int lans = sz(l) - l.order_of_key(v[i]);
        r.erase(v[i]);
        int rans = sz(r) - r.order_of_key(v[i]);
        l.insert(v[i]);
        ans += min(rans, lans);
    }
    cout << ans << el;

}

int main() {
    int t = 1;
    cout.tie(0);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    //  while (t--)acc();
    acc();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

13
39
40
32
100
13
16
15
28
27
26
25
24
23

output:

14

result:

ok single line: '14'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

4
3
2
1
10

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

13
40
80
90
60
100
20
53
52
51
50
49
48
47

output:

6

result:

ok single line: '6'

Test #4:

score: 0
Accepted
time: 7ms
memory: 4084kb

input:

10000
6048
7145
9278
4540
2505
6384
3715
7910
195
3426
9617
8881
3292
8975
7835
8954
160
5491
760
7767
1502
8277
852
6962
7901
7652
5673
4804
7214
4630
9962
672
6568
5301
179
3767
8589
3256
9022
1215
6827
1809
978
3787
5329
1295
2483
8331
4345
6805
7446
4695
5399
8550
5452
3968
3634
214
1348
6640
91...

output:

12538308

result:

ok single line: '12538308'

Test #5:

score: 0
Accepted
time: 107ms
memory: 8228kb

input:

100000
79611
99198
59215
12212
1068
20968
92768
4976
52551
71627
42534
9227
75293
84258
28203
3971
21644
10476
48090
31870
70655
39717
63939
36338
42901
51351
49298
76460
77186
50374
78750
38146
75785
80387
22773
56976
19956
18105
96559
16337
29650
82378
54109
30126
55031
29411
28918
96418
72024
213...

output:

1253664580

result:

ok single line: '1253664580'

Test #6:

score: -100
Wrong Answer
time: 62ms
memory: 8280kb

input:

100000
100000
99998
99996
99994
99992
99990
99988
99986
99984
99982
99980
99978
99976
99974
99972
99970
99968
99966
99964
99962
99960
99958
99956
99954
99952
99950
99948
99946
99944
99942
99940
99938
99936
99934
99932
99930
99928
99926
99924
99922
99920
99918
99916
99914
99912
99910
99908
99906
9990...

output:

-1795017296

result:

wrong answer 1st lines differ - expected: '2499950000', found: '-1795017296'