# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203544 | 2020-02-21T07:35:26 Z | blacktulip | Semiexpress (JOI17_semiexpress) | C++17 | 127 ms | 143612 KB |
#include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define pb push_back #define int long long #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 100000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 500005; const lo mod = 1000000007; int n,m,b,c,a,k,flag,t,vis[li],dp[3005][3005]; int cev,ans; string s; set<int> st,st1; vector<int> v; inline int f(int sira,int kac){ //~ cout<<sira<<" : : "<<kac<<endl; int cevv=-inf; if(kac<0)return -inf; if(sira>n){ //~ if(kac!=0)return -inf; return 0; } if(~dp[sira][kac])return dp[sira][kac]; if(vis[sira]){ //~ cout<<"**\n"; int bas=sira; int son=0; if(vis[sira]<(int)v.size()) son=v[vis[sira]]-1; else son=n; while(bas<=son){ if((sira-1)*b+(ort-sira)*a>t)son=ort-1; else bas=ort+1; } //~ cout<<"***\n"; if(son<sira){ cevv=max(cevv,f(n+1,kac)); //~ cevv=max(cevv,f(sira+1,kac-1)); } else{ cevv=max(cevv,f(son+1,kac)+son-sira+1); } } else{ //~ cout<<"()\n"; //~ cevv=max(cevv,f(sira+1,kac)); auto it1=st.upper_bound(sira); auto it=it1; //~ if(it==st.begin())cout<<"one\n"; it--; int bas=sira; int son=0; if(it1!=st.end()) son=*it1-1; else son=n-1; //~ if(sira==5)cout<<son<<"yess"<<*it1<<endl; while(bas<=son){ //~ if(sira==8){ //~ cout<<bas<<" ()() "<<son<<" ()() "<<ort<<" ()() "<<(*it-1)*b+(sira-*it)*c+(ort-sira)*a<<"DEBUG"<<endl; //~ } if((*it-1)*b+(sira-*it)*c+(ort-sira)*a>t)son=ort-1; else bas=ort+1; } //~ cout<<sira<<" : : "<<son<<endl; cevv=max(cevv,f(*it1,kac)); //~ if(son<sira)cevv=max(cevv,f(sira+1,kac)); cevv=max(cevv,f(son+1,kac-1)+son-sira+1); } return dp[sira][kac]=cevv; } main(void){ memset(dp,-1,sizeof(dp)); scanf("%lld %lld %lld",&n,&m,&k); scanf("%lld %lld %lld",&a,&b,&c); scanf("%lld",&t); for(int i=1;i<=m;i++){ int x; scanf("%lld",&x); vis[x]=i; v.pb(x); st.insert(x); k--; } cev=f(1,k); printf("%lld\n",--cev); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 71032 KB | Output is correct |
2 | Correct | 43 ms | 71032 KB | Output is correct |
3 | Correct | 43 ms | 71032 KB | Output is correct |
4 | Correct | 43 ms | 71036 KB | Output is correct |
5 | Correct | 42 ms | 71032 KB | Output is correct |
6 | Correct | 43 ms | 71036 KB | Output is correct |
7 | Correct | 42 ms | 71032 KB | Output is correct |
8 | Correct | 46 ms | 71032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 71032 KB | Output is correct |
2 | Correct | 43 ms | 71032 KB | Output is correct |
3 | Correct | 43 ms | 71032 KB | Output is correct |
4 | Correct | 43 ms | 71036 KB | Output is correct |
5 | Correct | 42 ms | 71032 KB | Output is correct |
6 | Correct | 43 ms | 71036 KB | Output is correct |
7 | Correct | 42 ms | 71032 KB | Output is correct |
8 | Correct | 46 ms | 71032 KB | Output is correct |
9 | Correct | 44 ms | 71032 KB | Output is correct |
10 | Correct | 42 ms | 71032 KB | Output is correct |
11 | Correct | 45 ms | 71032 KB | Output is correct |
12 | Correct | 43 ms | 71032 KB | Output is correct |
13 | Correct | 42 ms | 71032 KB | Output is correct |
14 | Correct | 45 ms | 71032 KB | Output is correct |
15 | Correct | 43 ms | 71032 KB | Output is correct |
16 | Correct | 44 ms | 71032 KB | Output is correct |
17 | Correct | 44 ms | 71032 KB | Output is correct |
18 | Correct | 44 ms | 71032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 71032 KB | Output is correct |
2 | Correct | 43 ms | 71032 KB | Output is correct |
3 | Correct | 43 ms | 71032 KB | Output is correct |
4 | Correct | 43 ms | 71036 KB | Output is correct |
5 | Correct | 42 ms | 71032 KB | Output is correct |
6 | Correct | 43 ms | 71036 KB | Output is correct |
7 | Correct | 42 ms | 71032 KB | Output is correct |
8 | Correct | 46 ms | 71032 KB | Output is correct |
9 | Correct | 44 ms | 71032 KB | Output is correct |
10 | Correct | 42 ms | 71032 KB | Output is correct |
11 | Correct | 45 ms | 71032 KB | Output is correct |
12 | Correct | 43 ms | 71032 KB | Output is correct |
13 | Correct | 42 ms | 71032 KB | Output is correct |
14 | Correct | 45 ms | 71032 KB | Output is correct |
15 | Correct | 43 ms | 71032 KB | Output is correct |
16 | Correct | 44 ms | 71032 KB | Output is correct |
17 | Correct | 44 ms | 71032 KB | Output is correct |
18 | Correct | 44 ms | 71032 KB | Output is correct |
19 | Runtime error | 127 ms | 143612 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
20 | Halted | 0 ms | 0 KB | - |