8000 solved 0x14 13144 · jo0n-lab/basic-algo-lecture@e627a47 · GitHub
[go: up one dir, main page]

Skip to content

Commit e627a47

Browse files
author
cuberry
committed
solved 0x14 13144
1 parent 6ea00a2 commit e627a47

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed

0x14/v13144/13144

26.3 KB
Binary file not shown.
File renamed without changes.

0x14/v13144/main

16.5 KB
Binary file not shown.

0x14/v13144/main.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define __INPUT__
5+
#define __PRINT__
6+
#define __DEBUG__
7+
8+
int N;
9+
int arr[100'002];
10+
int cache[100'002];
11+
12+
int main() {
13+
ios::sync_with_stdio(false);
14+
cin.tie(NULL);
15+
16+
cin >> N;
17+
for (int i = 1; i <= N; i++)
18+
cin >> arr[i];
19+
20+
int spos = 1;
21+
int epos = 1;
22+
// cache[arr[epos]]=1;
23+
long long ans = 0;
24+
25+
for (int spos = 1; spos <= N; spos++) {
26+
while (epos <= N && cache[arr[epos]] == 0) {
27+
cache[arr[epos]] = 1;
28+
epos++;
29+
}
30+
cache[arr[spos]] = 0;
31+
ans += epos - spos;
32+
}
33+
34+
cout << ans;
35+
}

0x14/v13144/tc1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
1 2 3 4 5

0x14/v13144/tc2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
1 2 3 1 2

0 commit comments

Comments
 (0)
0