# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
295205 |
2020-09-09T14:19:25 Z |
최은수(#5799) |
치료 계획 (JOI20_treatment) |
C++17 |
|
103 ms |
7536 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;
const int mx=100010;
struct fen
{
ll t[mx*2];
fen(){fill(t,t+mx*2,INF);}
inline void upd(int x,ll p)
{
for(x=mx*2-10-x;x<mx*2;x+=x&-x)
t[x]=min(t[x],p);
return;
}
inline ll query(int x)
{
ll ret=INF;
for(x=mx*2-10-x;x>0;x^=x&-x)
ret=min(ret,t[x]);
return ret;
}
}ft;
struct query
{
int t,l,r,c;
bool operator<(const query&x)const
{
return l<x.l;
}
};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin>>n>>m;
vector<query>qv(m);
vector<int>cpv;
for(auto&t:qv)
cin>>t.t>>t.l>>t.r>>t.c,cpv.eb(t.l),cpv.eb(t.r+1);
cpv.eb(1);
cpv.eb(n+1);
sort(all(cpv)),cpv.erase(unique(all(cpv)),cpv.end());
for(auto&t:qv)
t.l=upper_bound(all(cpv),t.l)-cpv.begin(),
t.r=upper_bound(all(cpv),t.r+1)-cpv.begin()-1;
sort(all(qv));
ft.upd(0,0);
for(auto&t:qv)
ft.upd(t.r,ft.query(t.l-1)+t.c);
ll ans=ft.query((int)cpv.size()-1);
if(ans==INF)
ans=-1;
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
4596 KB |
Output is correct |
2 |
Correct |
98 ms |
4596 KB |
Output is correct |
3 |
Correct |
79 ms |
6640 KB |
Output is correct |
4 |
Correct |
78 ms |
6652 KB |
Output is correct |
5 |
Correct |
60 ms |
7412 KB |
Output is correct |
6 |
Correct |
64 ms |
7536 KB |
Output is correct |
7 |
Correct |
73 ms |
7536 KB |
Output is correct |
8 |
Correct |
60 ms |
7536 KB |
Output is correct |
9 |
Correct |
67 ms |
7536 KB |
Output is correct |
10 |
Correct |
75 ms |
7536 KB |
Output is correct |
11 |
Correct |
99 ms |
7536 KB |
Output is correct |
12 |
Correct |
97 ms |
7536 KB |
Output is correct |
13 |
Correct |
103 ms |
7536 KB |
Output is correct |
14 |
Correct |
102 ms |
7536 KB |
Output is correct |
15 |
Correct |
100 ms |
7532 KB |
Output is correct |
16 |
Correct |
100 ms |
7448 KB |
Output is correct |
17 |
Correct |
99 ms |
6720 KB |
Output is correct |
18 |
Correct |
90 ms |
6916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1920 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1920 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
4596 KB |
Output is correct |
2 |
Correct |
98 ms |
4596 KB |
Output is correct |
3 |
Correct |
79 ms |
6640 KB |
Output is correct |
4 |
Correct |
78 ms |
6652 KB |
Output is correct |
5 |
Correct |
60 ms |
7412 KB |
Output is correct |
6 |
Correct |
64 ms |
7536 KB |
Output is correct |
7 |
Correct |
73 ms |
7536 KB |
Output is correct |
8 |
Correct |
60 ms |
7536 KB |
Output is correct |
9 |
Correct |
67 ms |
7536 KB |
Output is correct |
10 |
Correct |
75 ms |
7536 KB |
Output is correct |
11 |
Correct |
99 ms |
7536 KB |
Output is correct |
12 |
Correct |
97 ms |
7536 KB |
Output is correct |
13 |
Correct |
103 ms |
7536 KB |
Output is correct |
14 |
Correct |
102 ms |
7536 KB |
Output is correct |
15 |
Correct |
100 ms |
7532 KB |
Output is correct |
16 |
Correct |
100 ms |
7448 KB |
Output is correct |
17 |
Correct |
99 ms |
6720 KB |
Output is correct |
18 |
Correct |
90 ms |
6916 KB |
Output is correct |
19 |
Correct |
1 ms |
1920 KB |
Output is correct |
20 |
Incorrect |
1 ms |
1920 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |