Submission #66152


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A, class B> inline void chmod(A &a, const B b) { a = a%b; return; }
int main() {
int n, a[200000], b[200000];
long long ans, rev;
cin >> n;
for (int i=0; i<n; i++ ) {
cin >> a[i];
}
for (int i=0; i<n; i++ ) {
cin >> b[i];
}
ans = rev = 0;
for (int i=0; i<n; i++ ) {
ans += abs(a[i]-b[i]);
rev += abs(a[i]-b[n-i-1]);
}
cout << min(ans, rev+1) << endl;
return (0);
}

ステータス

項目 データ
問題 1435 - Same Sequence
ユーザー名 ei1929
投稿日時 2021-04-19 17:56:32
言語 C++17
状態 Accepted
得点 3
ソースコード長 696 Byte
最大実行時間 138 ms
最大メモリ使用量 2224 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 91 ms 1628 KB
1
in02.txt AC 108 ms 1548 KB
1
in03.txt AC 70 ms 1136 KB
1
in04.txt AC 89 ms 1508 KB
1
in05.txt AC 122 ms 1916 KB
1
in06.txt AC 119 ms 2000 KB
1
in07.txt AC 119 ms 2080 KB
1
in08.txt AC 121 ms 2028 KB
1
in09.txt AC 116 ms 2108 KB
1
in10.txt AC 87 ms 2064 KB
1
in11.txt AC 138 ms 2144 KB
1
in12.txt AC 117 ms 2224 KB
1
in13.txt AC 119 ms 2176 KB
1
in14.txt AC 17 ms 588 KB
1
in15.txt AC 55 ms 2084 KB
1
in16.txt AC 16 ms 624 KB
1
in17.txt AC 16 ms 716 KB
1
sample01.txt AC 17 ms 680 KB
1
sample02.txt AC 19 ms 640 KB
1