답안 #627088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627088 2022-08-12T06:56:05 Z Huseyn123 메기 농장 (IOI22_fish) C++17
3 / 100
494 ms 69200 KB
#include "fish.h"
#include <bits/stdc++.h>
#define MAX 300001
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
set<pll> a[MAX];
set<ll> b[MAX];
ll n,m,k;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W){
    n=N;
    m=M;
    for(int i=0;i<m;i++){
        a[X[i]].insert(make_pair(n-Y[i]-1,W[i]));
        b[X[i]].insert(n-Y[i]-1);
    }
    ll dp[n+1];
    dp[0]=0;
    dp[1]=0;
    ll h=n,sum=0;
    if(b[0].size()!=0){
        h=*b[0].begin();
        for(auto x:a[0]){
            sum+=x.second;
        }
        dp[1]=sum;
    }
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1];
        if(b[i-1].size()!=0){
            ll j;
            sum=0;
            j=distance(b[i-1].begin(),b[i-1].lower_bound(h-1));
            if(j==0){
                h=n;
            }
            else{
                h=*b[i-1].begin();
            }
            auto it=a[i-1].begin();
            ll z=0;
            while(it!=a[i-1].end() && z<j){
                dp[i]+=(*it).second;
                ++it;
                z++;
            }
            sum=0;
            for(auto x:a[i-1]){
                sum+=x.second;
            }
            if(sum+dp[i-2]>dp[i]){
                dp[i]=sum+dp[i-2];
                h=*b[i-1].begin();
            }
        }
        else{
            h=n;
        }
    }
    return dp[n];
}
/*
int main(){
    ll N,M;
    cin >> N >> M;
    vector <int> X(M),Y(M),W(M);
    for(int i=0;i<M;i++){
        cin >> X[i] >> Y[i] >> W[i];
    }
    ll res=max_weights(N,M,X,Y,W);
    cout << res << "\n";
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 39860 KB Output is correct
2 Correct 130 ms 42480 KB Output is correct
3 Correct 16 ms 29140 KB Output is correct
4 Correct 15 ms 29140 KB Output is correct
5 Correct 494 ms 69200 KB Output is correct
6 Correct 345 ms 69068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 28432 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 29140 KB Output is correct
2 Correct 14 ms 29140 KB Output is correct
3 Incorrect 52 ms 36264 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 28372 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 28372 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 28372 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 29140 KB Output is correct
2 Correct 14 ms 29140 KB Output is correct
3 Incorrect 52 ms 36264 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 39860 KB Output is correct
2 Correct 130 ms 42480 KB Output is correct
3 Correct 16 ms 29140 KB Output is correct
4 Correct 15 ms 29140 KB Output is correct
5 Correct 494 ms 69200 KB Output is correct
6 Correct 345 ms 69068 KB Output is correct
7 Incorrect 17 ms 28432 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -