Submission #61448

# Submission time Handle Problem Language Result Execution time Memory
61448 2018-07-26T03:58:30 Z 윤교준(#1780) Homecoming (BOI18_homecoming) C++11
0 / 100
1000 ms 12680 KB
#include "homecoming.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define revv(V) reverse(allv(V))
#define sz(V) ((int)(V).size())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

const int MAXN = 2000005;

int A[MAXN*2], B[MAXN*2];

bitset<MAXN> chk;

ll Ans;
int N, K;

ll f(int i) {
	ll ret = 0;
	for(int j = 0; j < K; j++)
		ret += B[i+j];
	return ret;
}
void g(int i) {
	for(int j = i; j < i+K; j++)
		B[j%N] = B[j%N+N] = 0;
}

ll solve(int _N, int _K, int *_A, int *_B) {
	N = _N; K = _K;
	for(int i = 0; i < N; i++) {
		A[i] = A[i+N] = _A[i];
		B[i] = B[i+N] = _B[i];
	}

	{
		ll sum = 0;
		for(int t = 0; t < N; t++) {
			pli p(-INFLL, -1);
			for(int i = 0; i < N; i++) if(!chk[i])
				upmax(p, pli(-f(i) + A[i], i));

			sum += p.first;
			upmax(Ans, sum);
			chk[p.second] = true;
			g(p.second);
		}
	}

	return Ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 44 ms 484 KB Output is correct
3 Runtime error 4 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 44 ms 484 KB Output is correct
3 Runtime error 4 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 12680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 44 ms 484 KB Output is correct
3 Runtime error 4 ms 852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -