Submission #64563


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
int main(){
int n;
cin >> n;
assert(1 <= n && n <= 2e5);
vector<int> a(n), b(n);
for(int i = 0; i < n; ++i){
cin >> a[i];
assert(1 <= a[i] && a[i] <= 1e9);
}
for(int i = 0; i < n; ++i){
cin >> b[i];
assert(1 <= b[i] && b[i] <= 1e9);
}
long long diff = 0, diff_rev = 0;
for(int i = 0; i < n; ++i){
diff += abs(a[i] - b[i]);
}
reverse(begin(a), end(a));
for(int i = 0; i < n; ++i){
diff_rev += abs(a[i] - b[i]);
}
cout << min(diff, diff_rev + 1) << '\n';
return (0);
}

ステータス

項目 データ
問題 1435 - Same Sequence
ユーザー名 ei1903
投稿日時 2020-11-04 16:49:09
言語 C++17
状態 Accepted
得点 3
ソースコード長 723 Byte
最大実行時間 136 ms
最大メモリ使用量 2180 KB

セット

セット 得点 Cases
1 ALL 3 / 3 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 92 ms 1628 KB
1
in02.txt AC 90 ms 1552 KB
1
in03.txt AC 65 ms 1152 KB
1
in04.txt AC 84 ms 1520 KB
1
in05.txt AC 116 ms 2180 KB
1
in06.txt AC 124 ms 1988 KB
1
in07.txt AC 112 ms 2056 KB
1
in08.txt AC 121 ms 2124 KB
1
in09.txt AC 113 ms 1936 KB
1
in10.txt AC 101 ms 2136 KB
1
in11.txt AC 136 ms 2080 KB
1
in12.txt AC 130 ms 2144 KB
1
in13.txt AC 118 ms 2088 KB
1
in14.txt AC 27 ms 624 KB
1
in15.txt AC 53 ms 2132 KB
1
in16.txt AC 20 ms 536 KB
1
in17.txt AC 19 ms 512 KB
1
sample01.txt AC 18 ms 612 KB
1
sample02.txt AC 18 ms 580 KB
1