結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2024-05-02 00:30:19 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 984 bytes | 
| コンパイル時間 | 3,789 ms | 
| コンパイル使用メモリ | 272,236 KB | 
| 実行使用メモリ | 15,616 KB | 
| 最終ジャッジ日時 | 2024-11-22 09:13:30 | 
| 合計ジャッジ時間 | 44,998 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 1 WA * 6 TLE * 12 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n, m;
    cin >>n >>m;
    int shade[n];
    int FishP[m];
    int Nshade[m];
    int Yshade[m];
    int Dist[m];
    int tot=0;
    int move=0;
    for(int i=0; i<n;i++){
        cin >> shade[i];
    }
    for(int i=0; i<m;i++){
        cin >> FishP[i] >> Nshade[i] >> Yshade[i];
    }
    for(int i=0; i<m; i++){
        Dist[i] =1e9+1;
        for(int j=0;j<n;j++){
            if (Dist[i]>abs(shade[j]-FishP[i])){
                Dist[i]=abs(shade[j]-FishP[i]);
            }
            else if(abs(shade[j]-FishP[i])==0){
                Dist[i]=abs(shade[j]-FishP[i]);
                break;
            }
            else{
                break;  
            }
            
        }
        if(Dist[i]<(Yshade[i]-Nshade[i])){
            move+=Dist[i];
            tot+=Yshade[i];
        }
        else{
            tot+=Nshade[i];
        }
    }
    cout << tot-move;
    return 0;
}
            
            
            
        