제출 #65274

#제출 시각아이디문제언어결과실행 시간메모리
65274FedericoSAliens (IOI16_aliens)C++14
16 / 100
215 ms4776 KiB
#include <iostream> #include <algorithm> #include "aliens.h" using namespace std; typedef long long int ll; int N,M,K; ll DP[1005][1005]; ll R[1005]; bool B[105][105]; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { N=n; M=m; K=k; if(N==K and N<=50){ ll ans=0; for(int i=0;i<N;i++) for(int a=min(r[i],c[i]);a<=max(r[i],c[i]);a++) for(int b=min(r[i],c[i]);b<=max(r[i],c[i]);b++) B[a][b]=true; for(int a=0;a<M;a++) for(int b=0;b<M;b++) if(B[a][b]) ans++; return ans; } sort(r.begin(),r.end()); for(int i=0;i<N;i++) R[i+1]=r[i]; for(int i=0;i<=N;i++) for(int k=0;k<=K;k++) DP[i][k]=1e18; DP[0][0]=0; for(int i=1;i<=N;i++) for(int k=1;k<=K;k++){ DP[i][k]=DP[i][k-1]; for(int j=0;j<i;j++) DP[i][k]=min(DP[i][k],DP[j][k-1]+(R[i]-R[j+1]+1)*(R[i]-R[j+1]+1)); } //for(int i=1;i<=N;i++)for(int k=1;k<=K;k++)cout<<i<<" "<<k<<" "<<DP[i][k]<<endl; return DP[N][K]; } /* 2 7 2 1 1 3 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...