답안 #944154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944154 2024-03-12T09:10:04 Z kxd 모임들 (IOI18_meetings) C++17
4 / 100
5500 ms 2076 KB
#include "meetings.h"
#include <bits/stdc++.h>
//#define DEBUG 1106
//#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define p_q priority_queue
#define m_p make_pair
#define pii pair<int,int>
#define endl '\n'
#define INIT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define forn(i,n) for (int i = 0; i < n; i++)
#define forn1(i,n) for (int i = 1; i <= n; i++)
#define all(x) x.begin(),x.end()
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl;
#else
#define debug(x) 1106;
#endif

using namespace std;
const int N = 2e5+5;
const int inf = 1e9;
const ll INF = 1e18;
const int MOD = 1e9+7;

int a[N];

int mxl[N], mxr[N];

vector<ll> minimum_costs(vector<int> h, vector<int> l, vector<int> r) {
  int n = h.size();
  int q = l.size();
  vector<ll> c(q);
  for (int j = 0; j < q; ++j) {
    ll ans = INF;
    for(int i = l[j]; i <= r[j]; i++) {
      ll t = 0;
      int mx = h[i];
      //cout << h[i] << '|';
      for(int k = i; k >= l[j]; k--) {
        chmax(mx,h[k]);
        t += mx;
        //cout << '(' << k << ',' << mx << ')';
      }
      mx = 0;
      for(int k = i+1; k <= r[j]; k++) {
        chmax(mx,h[k]);
        t += mx;
        //cout << '(' << k << ',' << mx << ')';
      }
      chmin(ans,t);
      //cout << i << ',' << t << endl;
    }
    c[j]=ans;
    //cout << ans << endl;
  }
  return c;
}
/*
    namespace {
    	int read_int() {
    		int x;
    		if (scanf("%d", &x) != 1) {
    			fprintf(stderr, "Error while reading input\n");
    			exit(1);
    		}
    		return x;
    	}
    }

    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:39:7: warning: unused variable 'n' [-Wunused-variable]
   39 |   int n = h.size();
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 16 ms 348 KB Output is correct
3 Correct 92 ms 344 KB Output is correct
4 Correct 29 ms 344 KB Output is correct
5 Correct 93 ms 348 KB Output is correct
6 Correct 10 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 4 ms 500 KB Output is correct
9 Correct 92 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 16 ms 348 KB Output is correct
3 Correct 92 ms 344 KB Output is correct
4 Correct 29 ms 344 KB Output is correct
5 Correct 93 ms 348 KB Output is correct
6 Correct 10 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 4 ms 500 KB Output is correct
9 Correct 92 ms 456 KB Output is correct
10 Execution timed out 5518 ms 600 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 5558 ms 2076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 5558 ms 2076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 16 ms 348 KB Output is correct
3 Correct 92 ms 344 KB Output is correct
4 Correct 29 ms 344 KB Output is correct
5 Correct 93 ms 348 KB Output is correct
6 Correct 10 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 4 ms 500 KB Output is correct
9 Correct 92 ms 456 KB Output is correct
10 Execution timed out 5518 ms 600 KB Time limit exceeded
11 Halted 0 ms 0 KB -