Submission #277019

# Submission time Handle Problem Language Result Execution time Memory
277019 2020-08-21T01:13:57 Z Masterdan Meetings (IOI18_meetings) C++14
19 / 100
761 ms 401172 KB
#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, v[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++){
            if(r[i]==j)ans=min(ans, mt[j][l[i]]);
            else
            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

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 time Memory Grader output
1 Correct 109 ms 196728 KB Output is correct
2 Correct 127 ms 196860 KB Output is correct
3 Correct 128 ms 196856 KB Output is correct
4 Correct 126 ms 196856 KB Output is correct
5 Correct 126 ms 196856 KB Output is correct
6 Correct 134 ms 196856 KB Output is correct
7 Correct 127 ms 196856 KB Output is correct
8 Correct 128 ms 196856 KB Output is correct
9 Correct 126 ms 196976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 196728 KB Output is correct
2 Correct 127 ms 196860 KB Output is correct
3 Correct 128 ms 196856 KB Output is correct
4 Correct 126 ms 196856 KB Output is correct
5 Correct 126 ms 196856 KB Output is correct
6 Correct 134 ms 196856 KB Output is correct
7 Correct 127 ms 196856 KB Output is correct
8 Correct 128 ms 196856 KB Output is correct
9 Correct 126 ms 196976 KB Output is correct
10 Correct 737 ms 197368 KB Output is correct
11 Correct 563 ms 197344 KB Output is correct
12 Correct 747 ms 197368 KB Output is correct
13 Correct 565 ms 197188 KB Output is correct
14 Correct 744 ms 197368 KB Output is correct
15 Correct 761 ms 197368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 196832 KB Output is correct
2 Runtime error 449 ms 401172 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 116 ms 196832 KB Output is correct
2 Runtime error 449 ms 401172 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 109 ms 196728 KB Output is correct
2 Correct 127 ms 196860 KB Output is correct
3 Correct 128 ms 196856 KB Output is correct
4 Correct 126 ms 196856 KB Output is correct
5 Correct 126 ms 196856 KB Output is correct
6 Correct 134 ms 196856 KB Output is correct
7 Correct 127 ms 196856 KB Output is correct
8 Correct 128 ms 196856 KB Output is correct
9 Correct 126 ms 196976 KB Output is correct
10 Correct 737 ms 197368 KB Output is correct
11 Correct 563 ms 197344 KB Output is correct
12 Correct 747 ms 197368 KB Output is correct
13 Correct 565 ms 197188 KB Output is correct
14 Correct 744 ms 197368 KB Output is correct
15 Correct 761 ms 197368 KB Output is correct
16 Correct 116 ms 196832 KB Output is correct
17 Runtime error 449 ms 401172 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -