結果

問題 No.2408 Lakes and Fish
ユーザー vjudge1vjudge1
提出日時 2024-05-02 00:30:19
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 984 bytes
コンパイル時間 6,493 ms
コンパイル使用メモリ 271,824 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-02 00:30:33
合計ジャッジ時間 9,012 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0