Submission #219002

# Submission time Handle Problem Language Result Execution time Memory
219002 2020-04-03T11:11:15 Z pavement Cloud Computing (CEOI18_clo) C++17
0 / 100
11 ms 1152 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
typedef long double ld;

int N, M, f, c, v, idx1, idx2, dp[100005];
vector<tuple<int, int, int> > F, S;
vector<pair<int, bool> > V;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1, c, f, v; i <= N; i++) {
		cin >> c >> f >> v;
		F.eb(-f, c, v);
	}
	cin >> M;
	for (int i = 1; i <= M; i++) {
		cin >> c >> f >> v;
		S.eb(-f, c, v);
	}
	sort(F.begin(), F.end());
	sort(S.begin(), S.end());
	while (idx1 < F.size() && idx2 < S.size())
		if (get<0>(F[idx1]) < get<0>(S[idx2])) V.eb(idx1++, 0);
		else V.eb(idx2++, 1);
	while (idx1 < F.size()) V.eb(idx1++, 0);
	while (idx2 < S.size()) V.eb(idx2++, 1);
	for (int i = N + M - 1; i >= 0; i--) {
		if (V[i].second)
			for (int j = 100000; j >= get<1>(S[V[i].first]); j--)
				dp[j] = max(dp[j], dp[j - get<1>(S[V[i].first])] + get<2>(S[V[i].first]));
		else
			for (int j = 0; j <= 100000 - get<1>(F[V[i].first]); j++)
				dp[j] = max(dp[j], dp[j + get<1>(F[V[i].first])] - get<2>(F[V[i].first]));
	}
	cout << *max_element(dp, dp + 100005) << '\n';
}

Compilation message

clo.cpp:15:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
clo.cpp: In function 'int main()':
clo.cpp:30:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (idx1 < F.size() && idx2 < S.size())
         ~~~~~^~~~~~~~~~
clo.cpp:30:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (idx1 < F.size() && idx2 < S.size())
                            ~~~~~^~~~~~~~~~
clo.cpp:33:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (idx1 < F.size()) V.eb(idx1++, 0);
         ~~~~~^~~~~~~~~~
clo.cpp:34:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (idx2 < S.size()) V.eb(idx2++, 1);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -