Submission #00045


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
signed main() {
int n, m, p[100000];
long long a, b, c;
int imos[100001] = {};
long long ans;
cin >> n >> m;
for ( int i = 0; i < m; i++ ) {
cin >> p[i];
p[i]--;
if ( i > 0 ) {
imos[min(p[i], p[i-1])] ++;
imos[max(p[i], p[i-1])] --;
}
}
for ( int i = 0; i < n-1; i++ ) {
imos[i+1] += imos[i];
}
ans = 0;
for ( int i = 0; i < n-1; i++ ) {
cin >> a >> b >> c;
ans += min(a*imos[i], b*imos[i]+c);
}
cout << ans << endl;
return (0);
}

ステータス

項目 データ
問題 0002 - 鉄道旅行
ユーザー名 ei1929
投稿日時 2020-12-08 17:33:59
言語 C++
状態 Accepted
得点 100
ソースコード長 653 Byte
最大実行時間 93 ms
最大メモリ使用量 1468 KB

セット

セット 得点 Cases
1 Subtask01 20 / 20 01-*
2 Subtask02 30 / 30 sample-*, 01-*, 02-*
3 Subtask03 50 / 50 sample-*, 01-*, 02-*, 03-*

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01-01.txt AC 20 ms 860 KB
1
2
3
01-02.txt AC 27 ms 828 KB
1
2
3
01-03.txt AC 21 ms 796 KB
1
2
3
01-04.txt AC 25 ms 760 KB
1
2
3
01-05.txt AC 17 ms 852 KB
1
2
3
01-06.txt AC 25 ms 824 KB
1
2
3
01-07.txt AC 22 ms 788 KB
1
2
3
01-08.txt AC 29 ms 1012 KB
1
2
3
02-01.txt AC 27 ms 976 KB
2
3
02-02.txt AC 22 ms 808 KB
2
3
02-03.txt AC 26 ms 896 KB
2
3
02-04.txt AC 19 ms 988 KB
2
3
02-05.txt AC 22 ms 944 KB
2
3
02-06.txt AC 20 ms 1036 KB
2
3
02-07.txt AC 16 ms 868 KB
2
3
02-08.txt AC 19 ms 960 KB
2
3
02-09.txt AC 21 ms 932 KB
2
3
02-10.txt AC 19 ms 900 KB
2
3
03-01.txt AC 64 ms 860 KB
3
03-02.txt AC 90 ms 1208 KB
3
03-03.txt AC 92 ms 1172 KB
3
03-04.txt AC 62 ms 888 KB
3
03-05.txt AC 89 ms 1360 KB
3
03-06.txt AC 88 ms 1456 KB
3
03-07.txt AC 75 ms 1164 KB
3
03-08.txt AC 91 ms 1308 KB
3
03-09.txt AC 93 ms 1396 KB
3
03-10.txt AC 75 ms 1100 KB
3
03-11.txt AC 92 ms 1372 KB
3
03-12.txt AC 89 ms 1468 KB
3
03-13.txt AC 89 ms 1432 KB
3
03-14.txt AC 88 ms 1396 KB
3
sample-01.txt AC 18 ms 972 KB
2
3
sample-02.txt AC 19 ms 932 KB
2
3