Submission #958526

# Submission time Handle Problem Language Result Execution time Memory
958526 2024-04-06T01:25:31 Z horiseun Catfish Farm (IOI22_fish) C++17
0 / 100
56 ms 5352 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include "fish.h"
using namespace std;

#define ll long long

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
	ll ans = 0;
	vector<int> col0, col1;
	for (int i = 0; i < M; i++) {
		if (X[i]) col1.push_back(i);
		else col0.push_back(i);
	}
	sort(col0.begin(), col0.end(), [&] (int x, int y) {
		return Y[x] < Y[y];
	});
	sort(col1.begin(), col1.end(), [&] (int x, int y) {
		return Y[x] > Y[y];
	});
	reverse(col0.begin(), col0.end());
	col0.push_back(-1);
	reverse(col0.begin(), col0.end());
	vector<int> pref(col0.size() + 1, 0);
	for (int i = 1; i < col0.size(); i++) {
		pref[i] = pref[i - 1] + W[col0[i]];
		col0[i] = Y[col0[i]];
	}
	ans = pref.back();
	ll tmp = 0;
	for (int i = 0; i < col1.size(); i++) {
		int idx = lower_bound(col0.begin(), col0.end(), Y[col1[i]]) - col0.begin();
		tmp += W[col1[i]];
		if (idx == 0) continue;
		idx--;
		ans = max(ans, pref[idx] + tmp);
	}
	return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (int i = 1; i < col0.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
fish.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i = 0; i < col1.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3028 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 56 ms 5352 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '40479737800179'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '4044', found: '6066'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3028 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '0'
2 Halted 0 ms 0 KB -