제출 #1278546

#제출 시각아이디문제언어결과실행 시간메모리
1278546trideserMeasures (CEOI22_measures)C++20
24 / 100
1596 ms2068 KiB
#include <bits/stdc++.h> using namespace std; long long solve(vector<int> coords, int D) { sort(coords.begin(), coords.end()); long long x = coords[0]; long long cost = 0; for(int i = 1; i < coords.size(); i++) { long long a = coords[i]; //cout << "\t" << x << " " << cost << " " << a << "\n"; if(a + cost - x >= D) { // move new as much left as possible without increasing cost x = max(x + D, a - cost); } else { // moving new right, increasing cost long long costinc = (D - (a + cost - x)) / 2; // cout << "\t" << costinc << " "; cost += costinc; x = a + cost; // cout << "\n"; } } return cost; } int main() { int N, M, D; cin >> N >> M >> D; vector<int> coordinates; for(int i = 0; i < N; i++) { int a; cin >> a; coordinates.push_back(2 * a); } for(int i = 0; i < M; i++) { int a; cin >> a; coordinates.push_back(2 * a); long long b = solve(coordinates, 2 * D); cout << b / 2; if(b & 0x1) { cout << ".5"; } cout << "\n"; } return 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...