Submission #6814998


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

int n, m, p;
long long x[2505], ans = LLONG_MIN;
vector<pair<int, long long>> v[2505];

int main() {
	scanf("%d%d%d", &n, &m, &p);
	for (int i = 2; i <= n; i++)
		x[i] = LLONG_MIN;
	while (m--) {
		int ta, tb, tc;
		scanf("%d%d%d", &ta, &tb, &tc);
		v[ta].emplace_back(tb, tc);
	}
	for (int i = 0; i <= n * 2; i++) {
		for (int j = 1; j <= n; j++)
			if (x[j] != LLONG_MIN)
				for (auto& k : v[j])
					x[k.first] = max(x[k.first], x[j] + k.second - p);
		if (i != n * 2) {
			ans = max(ans, x[n]);
			continue;
		}
		if (x[n] == ans)
			printf("%lld\n", max(0LL, ans));
		else
			puts("-1");
	}
}

Submission Info

Submission Time
Task E - Coins Respawn
User nhho
Language C++14 (GCC 5.4.1)
Score 0
Code Size 679 Byte
Status WA
Exec Time 89 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &m, &p);
                             ^
./Main.cpp:15:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &ta, &tb, &tc);
                                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 49
WA × 7
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54, b55, b56
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 46 ms 384 KB
b10 AC 39 ms 384 KB
b11 WA 41 ms 384 KB
b12 AC 47 ms 384 KB
b13 AC 47 ms 384 KB
b14 AC 39 ms 384 KB
b15 AC 2 ms 512 KB
b16 AC 2 ms 512 KB
b17 AC 2 ms 512 KB
b18 AC 38 ms 384 KB
b19 AC 39 ms 384 KB
b20 WA 39 ms 384 KB
b21 WA 39 ms 384 KB
b22 AC 10 ms 384 KB
b23 AC 38 ms 384 KB
b24 AC 10 ms 384 KB
b25 AC 10 ms 256 KB
b26 AC 87 ms 512 KB
b27 AC 86 ms 512 KB
b28 AC 89 ms 512 KB
b29 WA 86 ms 512 KB
b30 WA 87 ms 512 KB
b31 WA 87 ms 512 KB
b32 AC 84 ms 512 KB
b33 AC 85 ms 512 KB
b34 AC 84 ms 512 KB
b35 AC 87 ms 512 KB
b36 AC 84 ms 512 KB
b37 AC 86 ms 512 KB
b38 AC 85 ms 512 KB
b39 AC 87 ms 512 KB
b40 AC 83 ms 512 KB
b41 AC 85 ms 512 KB
b42 AC 84 ms 384 KB
b43 AC 75 ms 512 KB
b44 AC 78 ms 512 KB
b45 AC 76 ms 512 KB
b46 AC 76 ms 512 KB
b47 AC 11 ms 512 KB
b48 AC 35 ms 384 KB
b49 AC 41 ms 384 KB
b50 AC 39 ms 384 KB
b51 AC 39 ms 512 KB
b52 AC 39 ms 384 KB
b53 WA 38 ms 384 KB
b54 AC 77 ms 512 KB
b55 AC 67 ms 512 KB
b56 AC 62 ms 512 KB