답안 #710865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710865 2023-03-16T03:10:19 Z pavement Rainy Markets (CCO22_day1problem2) C++17
5 / 25
532 ms 90740 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using db = double;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

int N, ans, B[1000005], P[1000005], U[1000005], V[1000005], ml[1000005], mr[1000005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> B[i];
	}
	for (int i = 1; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 1; i < N; i++) {
		cin >> U[i];
		int tmp = P[i];
		P[i] = max(0ll, P[i] - U[i]);
		V[i] = tmp - P[i];
	}
	for (int i = 1; i < N; i++) {
		int tmp = B[i];
		B[i] = max(0ll, B[i] - P[i]);
		P[i] -= (tmp - B[i]);
		ml[i] = tmp - B[i];
		if (B[i + 1] < P[i]) return cout << "NO\n", 0;
		B[i + 1] -= P[i];
		mr[i] = P[i];
	}
	for (int i = 1; i < N; i++) {
		int tmp = B[i];
		B[i] = max(0ll, B[i] - V[i]);
		V[i] -= (tmp - B[i]);
		ml[i] += tmp - B[i];
		int tmp2 = B[i + 1];
		B[i + 1] = max(0ll, B[i + 1] - V[i]);
		V[i] -= (tmp2 - B[i + 1]);
		mr[i] += (tmp2 - B[i + 1]);
	}
	for (int i = 1; i < N; i++) {
		ans += V[i];
	}
	cout << "YES\n" << ans << '\n';
	for (int i = 1; i < N; i++) {
		cout << ml[i] << ' ' << V[i] << ' ' << mr[i] << '\n';
	}
}

Compilation message

Main.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 368 KB Output is correct
4 Correct 207 ms 47176 KB Output is correct
5 Correct 283 ms 53064 KB Output is correct
6 Correct 219 ms 62808 KB Output is correct
7 Correct 295 ms 68804 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 367 ms 59668 KB Output is correct
11 Correct 358 ms 62928 KB Output is correct
12 Correct 468 ms 88752 KB Output is correct
13 Correct 475 ms 83752 KB Output is correct
14 Correct 194 ms 46472 KB Output is correct
15 Correct 462 ms 90476 KB Output is correct
16 Correct 506 ms 90552 KB Output is correct
17 Correct 498 ms 90636 KB Output is correct
18 Correct 485 ms 90708 KB Output is correct
19 Correct 446 ms 90740 KB Output is correct
20 Correct 448 ms 90436 KB Output is correct
21 Correct 465 ms 90252 KB Output is correct
22 Correct 474 ms 87872 KB Output is correct
23 Correct 462 ms 90580 KB Output is correct
24 Correct 451 ms 89704 KB Output is correct
25 Correct 247 ms 53968 KB Output is correct
26 Correct 246 ms 53324 KB Output is correct
27 Correct 444 ms 90632 KB Output is correct
28 Correct 448 ms 88644 KB Output is correct
29 Correct 532 ms 90548 KB Output is correct
30 Correct 467 ms 90592 KB Output is correct
31 Correct 464 ms 89388 KB Output is correct
32 Correct 458 ms 90592 KB Output is correct
33 Correct 250 ms 53324 KB Output is correct
34 Correct 245 ms 53652 KB Output is correct
35 Correct 259 ms 53156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 2 ms 392 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 2 ms 392 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 368 KB Output is correct
4 Correct 207 ms 47176 KB Output is correct
5 Correct 283 ms 53064 KB Output is correct
6 Correct 219 ms 62808 KB Output is correct
7 Correct 295 ms 68804 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 367 ms 59668 KB Output is correct
11 Correct 358 ms 62928 KB Output is correct
12 Correct 468 ms 88752 KB Output is correct
13 Correct 475 ms 83752 KB Output is correct
14 Correct 194 ms 46472 KB Output is correct
15 Correct 462 ms 90476 KB Output is correct
16 Correct 506 ms 90552 KB Output is correct
17 Correct 498 ms 90636 KB Output is correct
18 Correct 485 ms 90708 KB Output is correct
19 Correct 446 ms 90740 KB Output is correct
20 Correct 448 ms 90436 KB Output is correct
21 Correct 465 ms 90252 KB Output is correct
22 Correct 474 ms 87872 KB Output is correct
23 Correct 462 ms 90580 KB Output is correct
24 Correct 451 ms 89704 KB Output is correct
25 Correct 247 ms 53968 KB Output is correct
26 Correct 246 ms 53324 KB Output is correct
27 Correct 444 ms 90632 KB Output is correct
28 Correct 448 ms 88644 KB Output is correct
29 Correct 532 ms 90548 KB Output is correct
30 Correct 467 ms 90592 KB Output is correct
31 Correct 464 ms 89388 KB Output is correct
32 Correct 458 ms 90592 KB Output is correct
33 Correct 250 ms 53324 KB Output is correct
34 Correct 245 ms 53652 KB Output is correct
35 Correct 259 ms 53156 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Incorrect 2 ms 392 KB Output isn't correct
45 Halted 0 ms 0 KB -