답안 #626324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626324 2022-08-11T11:42:03 Z boris_mihov 메기 농장 (IOI22_fish) C++17
0 / 100
1000 ms 4332 KB
#include "fish.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

typedef long long llong;
const int MAAXN2 = 100000 + 10;
const int MAXN = 3000 + 10;
const int INF  = 1e9;

int n, m;
struct Fish
{
    int x, y, w;
    inline friend bool operator < (const Fish &a, const Fish &b)
    {
        return a.x < b.x || (a.x == b.x && a.y < b.y);
    }

} fish[MAXN];

int table[MAXN][MAXN];

llong solveEven()
{
    llong ans = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        ans += fish[i].w;
    }

    return ans;
}

llong solveX01()
{
    llong sum[2];
    sum[0] = sum[1] = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        sum[fish[i].x] += fish[i].w; 
    }

    std::sort(fish+1, fish+1+n);
    int ptr0 = 1;
    int ptr1 = 1;
    while (ptr1 <= n && fish[ptr1].x == 0) ptr1++;
    if (ptr1 == n+1) return sum[0];

    sum[0] = 0;
    llong ans = sum[1];
    while (fish[ptr0].x == 0)
    {
        sum[0] += fish[ptr0].w;
        while (ptr1 <= n && fish[ptr1].y <= fish[ptr0].y)
        {
            sum[1] -= fish[ptr1].w;
            ++ptr1;
        }

        ans = std::max(sum[0], sum[1]);
    }

    return ans;
}

llong solveY0()
{
    llong ans = 0;
    return ans;
}

llong solveNSmall()
{
    llong ans = 0;
    return ans;
}

llong max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) 
{
    n = N;
    m = M;
    bool isEven = true;
    bool isX01 = true;
    bool isY0 = true;

    for (int i = 1 ; i <= N ; ++i)    
    {
        fish[i].x = X[i-1];
        fish[i].y = Y[i-1];
        fish[i].w = W[i-1];
        isEven &= (fish[i].x % 2 == 0);
        isX01 &= (fish[i].x <= 1);
        isY0 &= (fish[i].y == 0);
    }

    if (isEven) return solveEven();
    if (isX01) return solveX01();
    if (isY0) return solveY0();
    return solveNSmall();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 4332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 4332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -