Submission #817128

# Submission time Handle Problem Language Result Execution time Memory
817128 2023-08-09T09:44:20 Z enerelt14 Measures (CEOI22_measures) C++14
59 / 100
94 ms 6152 KB
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

#define ff first
#define ss second
#define ll long long

const int MX = 2e5 + 15;

int n, m, d;
int a[MX], b[MX];
pair<int, int> c[MX];

void go() {
	for(int j = 0; j < m; j++) {
		int ind = -1;
		for(int i = 0; i < n; i++) {
			if(a[i] > b[j]) {
				ind = i;
				break;
			}
		}
		if(ind == -1) ind = n;
		for(int i = n; i > ind; i--) a[i] = a[i - 1];
		a[ind] = b[j];
		n++;
		ll mx = 0, mn = 1e18, cur = 0;
		for(int i = 0; i < n - 1; i++) {
			cur += a[i + 1] - a[i] - d;
			mn = min(mn, cur - mx);
			mx = max(mx, cur);
		}
		if(mn > 0) cout << "0\n";
		else{
			cout << -mn / 2;
			if(mn % 2)cout << ".5\n";
			else cout << "\n";
		}
	}
}

int main() {
	cin >> n >> m >> d;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(a, a + n);
	if(n != 0) {
		go();
		return 0;
	}
	ll cur = 0, mx = 0, mn = 1e18;
	cout << "0\n";
	for(int i = 1; i < m; i++) {
		cur += b[i] - b[i - 1] - d;
		mn = min(mn, cur - mx);
		mx = max(mx, cur);
		if(mn > 0) cout << "0 ";
		else{
			cout << -mn / 2;
			if(mn % 2)cout << ".5 ";
			else cout << " ";
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 71 ms 996 KB Output is correct
10 Correct 68 ms 1068 KB Output is correct
11 Correct 64 ms 1236 KB Output is correct
12 Correct 75 ms 956 KB Output is correct
13 Correct 51 ms 1072 KB Output is correct
14 Correct 64 ms 1076 KB Output is correct
15 Correct 56 ms 1076 KB Output is correct
16 Correct 61 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 2136 KB Output is correct
2 Correct 72 ms 5964 KB Output is correct
3 Correct 70 ms 5960 KB Output is correct
4 Correct 69 ms 3704 KB Output is correct
5 Correct 70 ms 5076 KB Output is correct
6 Correct 74 ms 4100 KB Output is correct
7 Correct 68 ms 5024 KB Output is correct
8 Correct 69 ms 3780 KB Output is correct
9 Correct 67 ms 3776 KB Output is correct
10 Correct 71 ms 6152 KB Output is correct
11 Correct 70 ms 4532 KB Output is correct
12 Correct 94 ms 5464 KB Output is correct
13 Correct 67 ms 3752 KB Output is correct
14 Correct 70 ms 5696 KB Output is correct
15 Correct 70 ms 5492 KB Output is correct
16 Correct 57 ms 3400 KB Output is correct
17 Correct 69 ms 4980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 2136 KB Output is correct
2 Correct 72 ms 5964 KB Output is correct
3 Correct 70 ms 5960 KB Output is correct
4 Correct 69 ms 3704 KB Output is correct
5 Correct 70 ms 5076 KB Output is correct
6 Correct 74 ms 4100 KB Output is correct
7 Correct 68 ms 5024 KB Output is correct
8 Correct 69 ms 3780 KB Output is correct
9 Correct 67 ms 3776 KB Output is correct
10 Correct 71 ms 6152 KB Output is correct
11 Correct 70 ms 4532 KB Output is correct
12 Correct 94 ms 5464 KB Output is correct
13 Correct 67 ms 3752 KB Output is correct
14 Correct 70 ms 5696 KB Output is correct
15 Correct 70 ms 5492 KB Output is correct
16 Correct 57 ms 3400 KB Output is correct
17 Correct 69 ms 4980 KB Output is correct
18 Incorrect 71 ms 5308 KB Output isn't correct
19 Halted 0 ms 0 KB -