QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402529#8120. Dizalolfxxx#0 8ms6648kbC++171.3kb2024-04-30 19:32:562024-04-30 19:32:56

Judging History

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

  • [2024-04-30 19:32:56]
  • 评测
  • 测评结果:0
  • 用时:8ms
  • 内存:6648kb
  • [2024-04-30 19:32:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
bool be;
constexpr int N = 1e5 + 5;
int n, q, a[N], pos[N], b[N], ans[N], stk[N], top, nxt[N];
struct b1t {
	int t[N];
	inline void add(int u, int v)
	{
		while (u <= n) {
			t[u] += v;
			u += u & -u;
		}
	}
	inline int query(int u)
	{
		int res = 0;
		while (u) {
			res += t[u];
			u -= u & -u;
		}
		return res;
	}
}t;
int solve()
{
	int ans = n;
	for (int i = 1; i; i = nxt[i]) {
		ans += b[i];
	}
	return ans;
}
bool en;
int main()
{
	cerr << (&be - &en) / 1024.0 / 1024 << " MB\n--------------------------------" << endl;
#ifdef IAKIOI
	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) cin >> a[i], pos[a[i]] = i;
	for (int i = 1; i <= n; ++i) {
		b[i] = pos[i] - t.query(pos[i]) - 1;
		t.add(pos[i], 1);
	}
	int mn = n + 1;
	for (int i = n; i >= 1; --i) {
		if (i < n) nxt[a[i]] = mn;
		mn = min(mn, a[i]);
	}
	cout << solve() << ' ';
//	while (q--) {
//		int x;
//		cin >> x;
//		cout << ans[x] << '\n';
//	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

100 99
46 70 52 75 41 25 95 48 22 33 87 40 62 68 67 32 66 23 81 77 19 98 44 26 53 71 78 100 28 27 45 65 20 97 31 7 57 43 21 2 92 9 83 96 60 17 64 36 59 51 50 79 29 89 85 90 72 47 94 1 13 49 73 18 34 4 88 8 69 24 16 86 5 14 11 82 84 39 15 42 74 80 63 76 38 54 37 55 91 10 30 6 58 93 61 35 99 3 12 56
1...

output:

385 

result:

wrong answer 1st lines differ - expected: '385 381 376 372 367 363 359 35...33 29 27 24 22 18 14 10 7 3 2 1', found: '385 '

Subtask #2:

score: 0
Wrong Answer

Test #7:

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

input:

1000 999
397 791 298 686 48 757 423 45 56 303 81 529 867 12 968 942 267 266 24 913 638 402 83 23 1000 44 696 79 666 980 990 394 364 973 453 531 433 106 818 351 654 911 133 166 78 734 521 951 20 32 157 959 207 272 574 507 378 612 388 248 268 234 629 870 6 53 450 342 345 568 513 807 189 885 127 868 23...

output:

7427 

result:

wrong answer 1st lines differ - expected: '7427 7419 7411 7403 7395 7387 ...3 21 19 17 15 13 11 9 7 5 3 2 1', found: '7427 '

Subtask #3:

score: 0
Wrong Answer

Test #13:

score: 29
Accepted
time: 8ms
memory: 5784kb

input:

100000 0
54924 86680 6903 21832 40927 66171 81252 88524 28245 14552 91271 54026 35740 56985 15692 36932 95402 73102 23923 73831 71006 48839 93060 18198 63733 44453 57468 14772 55276 47920 75498 29303 66457 77987 87216 44118 69356 60547 64621 88829 33392 37409 82671 89052 27257 47176 29071 57064 8205...

output:

1199807 

result:

ok single line: '1199807 '

Test #14:

score: 29
Accepted
time: 5ms
memory: 5796kb

input:

100000 0
8999 45819 19859 80206 72336 7083 31594 22612 56754 8085 13475 72744 21210 98930 27074 73628 43767 38259 672 50182 22648 56230 28820 48610 99472 75793 54786 53724 23496 49639 42073 47519 94327 83133 72222 68433 29352 8285 52121 66785 53386 7689 44141 19353 79741 230 24401 19470 98187 23207 ...

output:

924722 

result:

ok single line: '924722 '

Test #15:

score: 29
Accepted
time: 4ms
memory: 6580kb

input:

100000 0
54523 4715 82051 74811 85835 4114 27012 92192 38674 21768 90431 99997 96994 80875 88263 71599 61263 88247 91949 24076 42219 7409 34217 52145 18330 19257 81306 35256 50137 46215 57174 39934 91271 35846 1891 19436 88664 29887 38752 17291 54833 45071 26078 72938 87862 97238 77211 88159 665 692...

output:

1070295 

result:

ok single line: '1070295 '

Test #16:

score: 29
Accepted
time: 8ms
memory: 5860kb

input:

100000 0
63060 36660 93338 6928 96623 73938 42782 99578 56479 93208 36774 24709 17556 10913 30653 92007 45024 27972 41670 91379 47298 42217 33108 57822 63904 24778 43251 62719 57115 94168 34019 48706 34357 52915 72764 19699 14064 45070 96667 32204 16580 56353 20785 51038 10069 85354 83635 57022 6523...

output:

614117 

result:

ok single line: '614117 '

Test #17:

score: 29
Accepted
time: 8ms
memory: 5864kb

input:

100000 0
31969 70310 33797 32062 86335 26296 69610 16758 71688 19406 84874 62484 66818 74918 72126 1859 63659 34507 90717 67713 51456 12123 95461 25785 34937 95181 8565 49977 97025 11480 64036 27616 82776 53249 49337 29458 85824 51226 55317 35623 8701 99269 85243 51803 47945 49070 2594 5936 1509 524...

output:

841343 

result:

ok single line: '841343 '

Test #18:

score: 29
Accepted
time: 8ms
memory: 5840kb

input:

100000 0
50595 95605 91755 98157 67499 87307 53056 5844 20140 11231 88892 59417 86085 15430 29981 88689 78533 81081 80602 90122 86717 22973 96895 36497 26834 92235 87418 60821 85742 89925 76324 21340 25464 49948 27482 18102 57866 91170 80780 43774 78087 49303 40565 86376 45664 61629 58818 93448 6101...

output:

825827 

result:

ok single line: '825827 '

Test #19:

score: 0
Wrong Answer
time: 7ms
memory: 6648kb

input:

100000 0
76807 66785 85951 79980 80062 68091 52534 79387 70157 99871 97555 54916 86699 56774 71744 53999 64974 72812 71632 78018 72629 60754 76336 59442 84431 55674 63158 86644 96314 90017 90447 75529 86099 72042 84065 63800 73063 54967 69687 59467 57216 74944 90775 76407 57071 74722 69624 66101 663...

output:

-1794867296 

result:

wrong answer 1st lines differ - expected: '2500100000', found: '-1794867296 '

Subtask #4:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 8ms
memory: 5864kb

input:

100000 99999
76716 17445 57488 73176 31972 39961 39448 70858 98651 77741 3708 81901 80738 57340 69351 12147 16019 68896 88575 99024 32477 90730 93291 71046 97609 93522 83899 58358 72553 20908 76191 47968 99675 25286 1553 4868 55744 26031 363 86013 82165 35985 71467 42381 95346 77891 14986 65396 6019...

output:

898276 

result:

wrong answer 1st lines differ - expected: '898276 898265 898255 898245 89...25 22 21 19 16 14 12 10 7 4 2 1', found: '898276 '