답안 #1044694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044694 2024-08-05T12:30:11 Z Dan4Life 메기 농장 (IOI22_fish) C++17
0 / 100
197 ms 481728 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = (int)1e5+10;
const int mxN2 = (int)3e2+10;
const ll LINF = (ll)2e18;
int n, m;
struct Fish{ int x, y; ll w; };
vector<Fish> fishes;
ll dp[mxN2][mxN2][mxN2];
ll pref[4][mxN];

ll max_weights(int N, int M, vi _X, vi _Y, vi _W) {
	n = N, m = M; ll ans = 0;
	for(int i = 0; i < m; i++) 
		fishes.pb({_X[i]+1,_Y[i]+1,_W[i]});
	sort(all(fishes),[&](Fish a, Fish b){
		if(a.x!=b.x) return a.x<b.x;
		return a.y<b.y;
	});
	if(fishes.back().x <=2){
		
		for(int i = 0; i < m; i++){
			auto [x,y,w] = fishes[i];
			pref[x][y]+=w;
		}
		for(int i = 0; i <= n; i++)
			for(int j = 1; j <= n; j++)
				pref[i][j]+=pref[i][j-1];
		for(int i = 0; i <= n; i++){
			ans = max({ans, pref[1][i], pref[2][i]});
		}
		return ans;
	}
}

Compilation message

fish.cpp: In function 'll max_weights(int, int, vi, vi, vi)':
fish.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 197 ms 481728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 170 ms 479572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4696 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4696 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4696 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 170 ms 479572 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 197 ms 481728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -