Submission #624719

#TimeUsernameProblemLanguageResultExecution timeMemory
624719moyindavidMeetings (IOI18_meetings)C++17
4 / 100
808 ms786432 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) { int n=H.size(),cost[n][n]; for(int i=0;i<n;i++){ cost[i][i]=H[i]; for(int j=i+1;j<n;j++)cost[i][j]=max(cost[i][j-1],H[j]); } for(int i=n-1;i>=0;i--){ for(int j=i-1;j>=0;j--)cost[i][j]=max(cost[i][j+1],H[j]); } int Q = L.size(); vector<long long> C(Q,3000000000007); long long left[n][n],right[n][n],temp=0; for(int i=0;i<n;i++)for(int j=0;j<n;j++){left[i][j]=0;right[i][j]=0;} for(int i=0;i<n;i++){ left[i][i]=cost[i][i]; for(int k=i-1;k>=0;k--){ left[k][i]=cost[k][i]+left[k+1][i]; } right[i][i]=cost[i][i]; for(int k=i+1;k<n;k++){ right[k][i]=cost[k][i]+right[k-1][i]; } } for (int j = 0; j < Q; ++j) { for(int i=L[j];i<=R[j];i++){ if(i==L[j])C[j]=min(C[j],right[R[j]][i]); else if(i==R[j])C[j]=min(C[j],left[L[j]][i]); else C[j]=min(C[j],-cost[i][i]+right[R[j]][i]+left[L[j]][i]); } } return C; }

Compilation message (stderr)

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:18:38: warning: unused variable 'temp' [-Wunused-variable]
   18 |     long long left[n][n],right[n][n],temp=0;
      |                                      ^~~~
#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...