Submission #277012

#TimeUsernameProblemLanguageResultExecution timeMemory
277012MasterdanMeetings (IOI18_meetings)C++14
0 / 100
110 ms196856 KiB
#include "meetings.h" #include <bits/stdc++.h> #define MAX 1e9+7 #define SMAX 1e18+7 #define all(a) a.begin (), a.end () #define F first #define S second #define MIN -1 #define pb push_back #define mk make_pair #define mem(a, c) memset(a, c, sizeof a) #define pp pop_back using namespace std; typedef long long int ll; typedef vector <int> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector <ll> vll; ll mt[5010][5010]; int n, q; vector<long long> minimum_costs(vector<int> H,vector<int> l,vector<int> r) { vll v; vll total; n=H.size (); q=l.size (); for(int i=0;i<n;i++)v.pb(H[i]); int sw=0; for(int i=0;i<n;i++){ if(v[i]>=2)sw=1; } mem(mt, 0); //if(sw){ for(int i=0;i<n;i++){ ll maxi=v[i]; mt[i][i]=v[i]; for(int j=i-1;j>=0;j--){ maxi=max(maxi, v[j]); mt[i][j]+=maxi+mt[i][j+1]; } maxi=max(v[i], v[i+1]); mt[i][i+1]=maxi; for(int j=i+2;j<n;j++){ maxi=max(maxi, mt[i][j]); mt[i][j]+=maxi+mt[i][j-1]; } } /*for(int i=0;i<n;i++){ for(int j=0;j<n;j++)cout<<mt[i][j]<<" "; cout<<endl; }*/ for(int i=0;i<q;i++){ ll ans=SMAX; for(int j=0;j<n;j++){ ans=min(ans, mt[j][l[i]]+mt[j][r[i]]); } total.pb(ans); } return total; // } } /* namespace { int read_int() { int x; if (scanf("%d", &x) != 1) { fprintf(stderr, "Error while reading input\n"); exit(1); } return x; } } // namespace int main() { int N = read_int(); int Q = read_int(); std::vector<int> H(N); for (int i = 0; i < N; ++i) { H[i] = read_int(); } std::vector<int> L(Q), R(Q); for (int j = 0; j < Q; ++j) { L[j] = read_int(); R[j] = read_int(); } std::vector<long long> C = minimum_costs(H, L, R); for (size_t j = 0; j < C.size(); ++j) { printf("%lld\n", C[j]); } return 0; } */

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:27:7: warning: variable 'sw' set but not used [-Wunused-but-set-variable]
   27 |   int sw=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...