답안 #626326

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

typedef long long llong;
const int MAXM = 300000 + 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[MAXM];

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 Incorrect 22 ms 3156 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 724 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 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 3156 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '0'
2 Halted 0 ms 0 KB -