답안 #295170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
295170 2020-09-09T14:05:41 Z 최은수(#5799) 치료 계획 (JOI20_treatment) C++17
5 / 100
138 ms 5112 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
struct query
{
    int t,l,r,c;
    bool operator<(const query&x)const
    {
        return t<x.t;
    }
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<query>qv(m);
    for(auto&t:qv)
        cin>>t.t>>t.l>>t.r>>t.c;
    sort(all(qv));
    ll ans=INF;
    for(int i=1;i<(1<<m);i++)
    {
        vector<pi>itv;
        int pt=0;
        ll val=0;
        for(int j=0;j<m;j++)
        {
            if((i>>j&1)==0)
                continue;
            val+=qv[j].c;
            for(pi&t:itv)
            {
                if(t.fi>1)
                    t.fi+=qv[j].t-pt;
                if(t.se<n)
                    t.se-=qv[j].t-pt;
            }
            pt=qv[j].t;
            vector<pi>nitv;
            itv.eb(qv[j].l,qv[j].r);
            sort(all(itv));
            pi cur=itv[0];
            for(pi&t:itv)
            {
                if(t.fi>t.se)
                    continue;
                if(cur.se+1>=t.fi)
                    cur.se=max(cur.se,t.se);
                else
                    nitv.eb(cur),cur=t;
            }
            nitv.eb(cur);
            itv=nitv;
        }
        if((int)itv.size()==1&&itv[0]==pi(1,n))
            ans=min(ans,val);
    }
    if(ans==INF)
        ans=-1;
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 71 ms 384 KB Output is correct
3 Correct 70 ms 384 KB Output is correct
4 Correct 75 ms 504 KB Output is correct
5 Correct 76 ms 384 KB Output is correct
6 Correct 60 ms 384 KB Output is correct
7 Correct 81 ms 384 KB Output is correct
8 Correct 100 ms 384 KB Output is correct
9 Correct 81 ms 384 KB Output is correct
10 Correct 92 ms 384 KB Output is correct
11 Correct 138 ms 384 KB Output is correct
12 Correct 70 ms 384 KB Output is correct
13 Correct 71 ms 384 KB Output is correct
14 Correct 57 ms 384 KB Output is correct
15 Correct 67 ms 384 KB Output is correct
16 Correct 85 ms 384 KB Output is correct
17 Correct 109 ms 384 KB Output is correct
18 Correct 58 ms 384 KB Output is correct
19 Correct 86 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 71 ms 384 KB Output is correct
3 Correct 70 ms 384 KB Output is correct
4 Correct 75 ms 504 KB Output is correct
5 Correct 76 ms 384 KB Output is correct
6 Correct 60 ms 384 KB Output is correct
7 Correct 81 ms 384 KB Output is correct
8 Correct 100 ms 384 KB Output is correct
9 Correct 81 ms 384 KB Output is correct
10 Correct 92 ms 384 KB Output is correct
11 Correct 138 ms 384 KB Output is correct
12 Correct 70 ms 384 KB Output is correct
13 Correct 71 ms 384 KB Output is correct
14 Correct 57 ms 384 KB Output is correct
15 Correct 67 ms 384 KB Output is correct
16 Correct 85 ms 384 KB Output is correct
17 Correct 109 ms 384 KB Output is correct
18 Correct 58 ms 384 KB Output is correct
19 Correct 86 ms 384 KB Output is correct
20 Incorrect 26 ms 512 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -