結果
| 問題 |
No.2408 Lakes and Fish
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-08-14 15:27:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 753 bytes |
| コンパイル時間 | 315 ms |
| コンパイル使用メモリ | 41,924 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 13:47:09 |
| 合計ジャッジ時間 | 3,600 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2408.cc: No.2408 Lakes and Fish - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
const int MAX_M = 100000;
const int INF = 1 << 30;
/* typedef */
typedef long long ll;
/* global variables */
int ls[MAX_N];
/* subroutines */
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", ls + i);
ll sum = 0;
while (m--) {
int f, b, w;
scanf("%d%d%d", &f, &b, &w);
int k = lower_bound(ls, ls + n, f) - ls;
int c0 = (k > 0) ? f - ls[k - 1] : INF;
int c1 = (k < n) ? ls[k] - f : INF;
int c = min(c0, c1);
sum += max(b, w - c);
}
printf("%lld\n", sum);
return 0;
}
tnakao0123