Submission #00007


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int64 INF = 1LL << 58;
int main()
{
int D, N, T[200], A[200], B[200], C[200];
int dp[201][200];
fill_n(*dp, 201 * 200, -1);
cin >> D >> N;
for(int i = 0; i < D; i++) {
cin >> T[i];
}
for(int i = 0; i < N; i++) {
cin >> A[i] >> B[i] >> C[i];
if(A[i] <= T[0] && T[0] <= B[i]) dp[0][i] = 0;
}
for(int i = 1; i < D; i++) {
for(int j = 0; j < N; j++) {
if(dp[i - 1][j] == -1) continue;
for(int k = 0; k < N; k++) {
if(A[k] <= T[i] && T[i] <= B[k]) {
dp[i][k] = max(dp[i][k], dp[i - 1][j] + abs(C[j] - C[k]));
}
}
}
}
cout << *max_element(dp[D - 1], dp[D]) << endl;
}

ステータス

項目 データ
問題 0004 - 暑い日々 (Hot days)
ユーザー名 ei1333
投稿日時 2015-11-13 16:26:46
言語 C++11
状態 Accepted
得点 100
ソースコード長 764 Byte
最大実行時間 18 ms
最大メモリ使用量 804 KB

セット

セット 得点 Cases
1 入力1 20 / 20 *1.txt
2 入力2 20 / 20 *2.txt
3 入力3 20 / 20 *3.txt
4 入力4 20 / 20 *4.txt
5 入力5 20 / 20 *5.txt

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2013-yo-t4-in1.txt AC 13 ms 604 KB
1
2013-yo-t4-in2.txt AC 11 ms 804 KB
2
2013-yo-t4-in3.txt AC 16 ms 756 KB
3
2013-yo-t4-in4.txt AC 18 ms 572 KB
4
2013-yo-t4-in5.txt AC 17 ms 648 KB
5