# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
71242 |
2018-08-24T08:45:36 Z |
khohko |
매트 (KOI15_mat) |
C++17 |
|
1000 ms |
24768 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e6+100))
#define ARRS ((ll)(2e6+100))
#define HS ((ll)(1049))
#define MOD ((ll)(1000000861))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;
string s,t;
vector<pair<pair<ll,ll> ,pair<ll,ll> > > a;
vector<pair<pair<ll,ll> ,pair<ll,ll> > > b;
ll dp[4100][4100];
int main(){
#ifdef KHOKHO
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
ll n,w,l,r,d,k,c;
cin>>n>>w;
a.pb({{0,0},{-1,0}});
b.pb({{0,0},{w+1,0}});
for(int i=0; i<n; i++){
cin>>k;
if(k){
cin>>l>>r>>d>>c;
a.pb({{l,r},{d,c}});
}
else {
cin>>l>>r>>d>>c;
b.pb({{l,r},{w-d,c}});
}
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
for(int i=0; i<=a.size(); i++)
for(int j=0; j<=b.size(); j++)
dp[i][j]=-MAX;
dp[0][0]=0;
ll pas=0;
for(int i=0; i<a.size(); i++){
for(int j=0; j<b.size(); j++){
if(!i&&!j)continue;
if(b[j].fr.fr<=a[i].fr.fr&&(a[i].fr.fr>=b[j].fr.sc||a[i].sc.fr<=b[j].sc.fr)){
for(int k=0; k<i; k++){
if(a[k].fr.sc<=a[i].fr.fr)
dp[i][j]=max(dp[i][j],dp[k][j]+a[i].sc.sc);
}
}
if(b[j].fr.fr>=a[i].fr.fr&&(b[j].fr.fr>=a[i].fr.sc||a[i].sc.fr<=b[j].sc.fr)){
for(int k=0; k<j; k++){
if(b[k].fr.sc<=b[j].fr.fr)
dp[i][j]=max(dp[i][j],dp[i][k]+b[j].sc.sc);
}
}
//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
pas=max(pas,dp[i][j]);
}
}
cout<<pas;
}
Compilation message
mat.cpp: In function 'int main()':
mat.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<=a.size(); i++)
~^~~~~~~~~~
mat.cpp:45:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<=b.size(); j++)
~^~~~~~~~~~
mat.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<a.size(); i++){
~^~~~~~~~~
mat.cpp:50:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<b.size(); j++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
3 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
2 ms |
728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1004 KB |
Output is correct |
2 |
Correct |
5 ms |
1260 KB |
Output is correct |
3 |
Correct |
4 ms |
1276 KB |
Output is correct |
4 |
Correct |
5 ms |
1276 KB |
Output is correct |
5 |
Correct |
5 ms |
1344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1344 KB |
Output is correct |
2 |
Correct |
22 ms |
1344 KB |
Output is correct |
3 |
Correct |
29 ms |
1344 KB |
Output is correct |
4 |
Correct |
23 ms |
1344 KB |
Output is correct |
5 |
Correct |
17 ms |
1344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
24768 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
24768 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |