답안 #426635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426635 2021-06-14T08:23:34 Z 장태환(#7571) Bodyguard (JOI21_bodyguard) C++17
7 / 100
698 ms 871156 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#define int long long
using namespace std;
int N,Q;
int T[2900],A[2900],B[2900],C[2900];
int P[2900],X[2900];
int dp[6400][6400];
int verc[6400][6400];
int horc[6400][6400];
vector<int>pl;
vector<int>ml;
signed  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N>>Q;
    int i;
    for(i=0;i<N;i++)
    {
        cin >> T[i]>>A[i]>>B[i]>>C[i];
        if(A[i]>B[i])
        {
            ml.push_back(T[i]-A[i]);
            pl.push_back(T[i]+A[i]);
            ml.push_back(T[i]+A[i]-2*B[i]);
        }
        else
        {
            ml.push_back(T[i]-A[i]);
            pl.push_back(T[i]+A[i]);
            pl.push_back(T[i]+B[i]*2-A[i]);
        }
    }
    for(i=0;i<Q;i++)
    {
        cin >>P[i]>>X[i];
        ml.push_back(P[i]-X[i]);
        pl.push_back(P[i]+X[i]);
    }
    sort(ml.begin(),ml.end());
    sort(pl.begin(),pl.end());
    ml.erase(unique(ml.begin(),ml.end()),ml.end());
    pl.erase(unique(pl.begin(),pl.end()),pl.end());
    for(i=0;i<N;i++)
    {
        if(A[i]>B[i])
        {
            int s=lower_bound(ml.begin(),ml.end(),T[i]-A[i])-ml.begin();
            int c=lower_bound(pl.begin(),pl.end(),T[i]+A[i])-pl.begin();
            int e=lower_bound(ml.begin(),ml.end(),T[i]+A[i]-2*B[i])-ml.begin();
            int j;
            for(j=s;j<e;j++)
            {
                verc[j+1][c]+=C[i]*(ml[j+1]-ml[j])/2;
            }
        }
        else
        {
            int c=lower_bound(ml.begin(),ml.end(),T[i]-A[i])-ml.begin();
            int s=lower_bound(pl.begin(),pl.end(),T[i]+A[i])-pl.begin();
            int e=lower_bound(pl.begin(),pl.end(),T[i]-A[i]+2*B[i])-pl.begin();
            int j;
            for(j=s;j<e;j++)
            {
                horc[c][j+1]+=C[i]*(pl[j+1]-pl[j])/2;
            }
        }
    }
    memset(dp,-60,sizeof(dp));
    dp[ml.size()-1][pl.size()-1]=0;
    for(int i=ml.size()-1;i>=0;i--)
        {
        int j;
        for(j=pl.size()-1;j>=0;j--)
        {
                dp[i][j]=max(dp[i][j],dp[i+1][j]+verc[i+1][j]);
                dp[i][j]=max(dp[i][j],dp[i][j+1]+horc[i][j+1]);
            }        }


    for(i=0;i<Q;i++)
    {

        int s=lower_bound(ml.begin(),ml.end(),P[i]-X[i])-ml.begin();
        int e=lower_bound(pl.begin(),pl.end(),P[i]+X[i])-pl.begin();
        cout <<dp[s][e]<<'\n';
    }

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 453 ms 509960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 369 ms 470380 KB Output is correct
2 Correct 367 ms 469556 KB Output is correct
3 Correct 384 ms 466904 KB Output is correct
4 Correct 186 ms 343968 KB Output is correct
5 Correct 391 ms 403268 KB Output is correct
6 Correct 348 ms 376524 KB Output is correct
7 Correct 398 ms 402788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 369 ms 470380 KB Output is correct
2 Correct 367 ms 469556 KB Output is correct
3 Correct 384 ms 466904 KB Output is correct
4 Correct 186 ms 343968 KB Output is correct
5 Correct 391 ms 403268 KB Output is correct
6 Correct 348 ms 376524 KB Output is correct
7 Correct 398 ms 402788 KB Output is correct
8 Runtime error 698 ms 871156 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 369 ms 470380 KB Output is correct
2 Correct 367 ms 469556 KB Output is correct
3 Correct 384 ms 466904 KB Output is correct
4 Correct 186 ms 343968 KB Output is correct
5 Correct 391 ms 403268 KB Output is correct
6 Correct 348 ms 376524 KB Output is correct
7 Correct 398 ms 402788 KB Output is correct
8 Runtime error 698 ms 871156 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 453 ms 509960 KB Output isn't correct
2 Halted 0 ms 0 KB -