Submission #1272370

#TimeUsernameProblemLanguageResultExecution timeMemory
1272370sasdeWatching (JOI13_watching)C++20
50 / 100
262 ms4964 KiB
#include<bits/stdc++.h> using namespace std; bool M1; #define PI 3.14159265358979323846 #define sz(a) (int)a.size() #define all(x) x.begin(),x.end() #define ii pair<int,int> #define iii pair<int,ii> #define iv pair<ii,ii> #define se second #define fi first #define ffi fi.fi #define sfi se.fi #define sse se.se #define fse fi.se #define lt(i, c, d) for(int i = c; i <= d; ++i) #define fl(i, c, d) for(int i = d; i >= c; --i) #define pb push_back #define emb emplace_back #define emf emplace_front #define em emplace #define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<'\n' #define look_time cerr << "TIME : " << clock() * 0.001 << "s" <<'\n' const int N=1e2+5,lg=30,mod=998244353; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int Rand(int u,int v){ return u+rd()%(v-u+1); } int dx[]={1,0,-1,0,1,1,-1,-1}; int dy[]={0,-1,0,1,1,-1,1,-1}; int node,a[N],p,q; int dp[N][N][N]; bool M2; void solve(){ cin >> node >> p >> q; p=min(p,node); q=min(q,node); for(int i=1;i<=node;++i){ cin >> a[i]; } sort(a+1,a+1+node); memset(dp,0x3f,sizeof dp); a[0]=a[1]; // dp[1][0][0]=0; dp[0][0][0]=0; for(int i=1;i<=node;++i){ for(int k=0;k<=q;++k){ for(int l=0;l<=p;++l){ for(int j=1;j<=i;++j){ int val=a[i]-a[j]+1; if(k>0){ // cout <<i<<" "<<j<<" "<<val<<'\n'; dp[i][k][l]=min(dp[i][k][l],max(dp[j-1][k-1][l],val/2+val%2)); // if(i==4&&k==0&&l==2) // cout <<j<<" "<<k<<" "<<l<<" "<<val/2+val%2<<" "<<dp[j-1][k-1][l]<<'\n'; } if(l>0){ dp[i][k][l]=min(dp[i][k][l],max(dp[j-1][k][l-1],val)); // if(i==3&&k==0&&l==1) // cout <<j<<" "<<k<<" "<<l<<" "<<val<<" "<<dp[j-1][k][l-1]<<'\n'; } } } } } // cout <<dp[11][2][2]; // for(int i=1;i<=node;++i)cout << a[i]<<" "; int ans=1e9; for(int i=0;i<=q;++i){ for(int j=0;j<=p;++j){ ans=min(ans,dp[node][i][j]); // cout <<dp[node][i][j]<<" "; } // cout<<'\n'; } cout << ans; } main() { srand(time(0)); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define task "paleta" if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int t=1; solve();cout<<'\n'; look_memory; look_time; }

Compilation message (stderr)

watching.cpp:80:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   80 | main()
      | ^~~~
watching.cpp: In function 'int main()':
watching.cpp:88:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |       freopen(task".inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
watching.cpp:89:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |       freopen(task".out","w",stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...