結果
| 問題 |
No.614 壊れたキャンパス
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-22 15:42:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,417 bytes |
| コンパイル時間 | 830 ms |
| コンパイル使用メモリ | 67,444 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2024-06-24 20:08:05 |
| 合計ジャッジ時間 | 5,104 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 5 RE * 11 |
ソースコード
#include <iostream>
#include <map>
using namespace std;
int main() {
unsigned int tmpA;
unsigned long tmpB, tmpC;
unsigned int n;
unsigned int m;
unsigned long k;
unsigned long start, terminate;
map<unsigned int, unsigned long> maxCorridor;
unsigned long sumCorridor=0;
cin>>n>>m>>k>>start>>terminate;
if(start<terminate) {
for (int i = 0; i < m; i++) {
cin >> tmpA >> tmpB >> tmpC;
if (maxCorridor.count(tmpA) == 0 || maxCorridor[tmpA] < tmpC - tmpB)
maxCorridor[tmpA] = tmpC - tmpB;
}
for (unsigned int i = 1; i < n; ++i) {
if (maxCorridor.count(i) == 0) {
cout << "-1" << endl;
return 1;
}
sumCorridor += maxCorridor[i];
}
cout << terminate - start - sumCorridor << endl;
}
else
{
for (int i = 0; i < m; i++) {
cin >> tmpA >> tmpB >> tmpC;
if (maxCorridor.count(tmpA) == 0 || maxCorridor[tmpA] < tmpB - tmpC)
maxCorridor[tmpA] = tmpB - tmpC;
}
for (unsigned int i = 1; i < n; ++i) {
if (maxCorridor.count(i) == 1) {
cout << "-1" << endl;
return 1;
}
sumCorridor += maxCorridor[i];
}
cout << start - terminate - sumCorridor << endl;
}
return 0;
}