QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574868#3936. Expecting RainWeaRD276AC ✓550ms130708kbC++203.4kb2024-09-19 03:54:562024-09-19 03:54:57

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 03:54:57]
  • 评测
  • 测评结果:AC
  • 用时:550ms
  • 内存:130708kb
  • [2024-09-19 03:54:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#include  <ext/pb_ds/assoc_container.hpp>
#include  <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int ll

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<long long, long long> > vpll;
typedef set<int> si;
typedef set<long long> sll;
typedef map<int, int> mii;
typedef map<long long, long long> mll;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

constexpr int INF = 1e9 + 47;
constexpr long long LINF = (ll) 1e18 + 4747;
constexpr int MOD = 998244353;
constexpr int N = 1e5 + 47;

int solve()
{
	int d, t, c, r;
	if (!(cin >> d >> t >> c >> r))
		return 1;
	
	vector<pair<pair<int, bool>, db>> events;
	FOR (i, 0, c)
	{
		int s, e, a;
		db pr;
		cin >> s >> e >> pr >> a;
		events.PB(MP(MP(s, false), a * pr));
		events.PB(MP(MP(e, true), a * pr));
	}
	vector<bool> roof(d + 1);
	FOR (i, 0, r)
	{
		int st, eee;
		cin >> st >> eee;
		FOR (j, st, eee)
			roof[j] = 1;
	}
	
	sort(ALL(events));
	
	vd exp(t + 1);
	int idx = 0;
	db curr = 0;
	FOR (i, 0, t + 1)
	{
		while (idx < SZ(events) && events[idx].F.F == i)
		{
			//cout << "-_-\n";
			if (!events[idx].F.S)
				curr += events[idx].S;
			else
				curr -= events[idx].S;
			idx++;
		}
		//cout << curr << '\n';
		exp[i] = curr;
	}
	vd pexp(t + 2);
	FOR (i, 1, t + 2)
		pexp[i] = pexp[i - 1] + exp[i - 1];
	
	vector dp(d + 1, vd(t + 1, LINF));
	FOR (i, 0, t + 1)
		dp[0][i] = 0;
		
	//FOR (i, 0, t + 1)
		//cout << exp[i] << ' ';
	//cout << '\n';
		
	FOR (i, 1, d + 1)
	{
		FOR (j, i, t + 1)
		{
			//cout << roof[i] << '\n';
			if (roof[i])
			{
				dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + exp[j - 1]);
				if (roof[i - 1])
					dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1]);
			}
			else
			{
				dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + exp[j - 1]);
				if (roof[i - 1])
					dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
			}
				
			//cout << "exp = " << exp[j] << '\n';
			//cout << "i = " << i << " j = " << j << " dp = " << dp[i][j] << '\n';
		}
	}
	
	cout << fixed << setprecision(6) << dp[d][t] << '\n';
	
	return 0;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4092kb

input:

20 60 2 1
5 15 0.33333 30
22 60 0.66666 70
0 10

output:

466.662000

result:

ok found '466.66200', expected '466.66200', error '0.00000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

3 4 2 1
1 3 0.25 8
2 4 0.66667 15
1 2

output:

10.000050

result:

ok found '10.00005', expected '10.00005', error '0.00000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

3 4 1 0
0 2 0.25 8

output:

2.000000

result:

ok found '2.00000', expected '2.00000', error '0.00000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 4080kb

input:

3 5 2 1
0 3 0.125 32
2 5 0.5 32
3 4

output:

28.000000

result:

ok found '28.00000', expected '28.00000', error '0.00000'

Test #5:

score: 0
Accepted
time: 3ms
memory: 4024kb

input:

26 60 6136 4
0 60 0.547910 73
39 41 0.094359 67
0 60 0.988482 20
0 60 0.242599 33
0 60 0.634549 66
10 20 0.977864 91
32 44 0.568210 81
0 60 0.530795 65
31 45 0.546480 48
42 43 0.130030 83
0 60 0.108433 42
0 60 0.103571 79
8 38 0.891536 33
54 57 0.833739 29
11 58 0.909730 70
0 60 0.858985 2
41 57 0.7...

output:

1338712.212675

result:

ok found '1338712.21268', expected '1338712.21268', error '0.00000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 4204kb

input:

5 60 5946 1
37 52 0.266686 69
0 60 0.723227 36
47 56 0.256874 72
0 60 0.226420 22
0 60 0.988650 80
0 60 0.267332 77
0 60 0.678345 22
0 60 0.974518 76
59 60 0.324089 49
0 60 0.792417 92
0 60 0.930750 44
0 60 0.258607 56
57 59 0.177228 58
57 59 0.182235 65
0 60 0.907016 20
0 60 0.080275 20
53 58 0.983...

output:

165823.407483

result:

ok found '165823.40748', expected '165823.40748', error '0.00000'

Test #7:

score: 0
Accepted
time: 7ms
memory: 4356kb

input:

30 70 14000 1
15 29 0.325545 79
0 70 0.400070 16
0 70 0.145223 38
51 64 0.250562 23
0 70 0.657686 86
0 70 0.849698 60
5 55 0.791354 17
0 70 0.408852 47
32 44 0.512728 20
0 70 0.760533 89
36 47 0.165419 15
0 70 0.262640 5
13 67 0.057902 90
0 70 0.077117 59
0 70 0.726827 21
37 70 0.755209 27
0 70 0.49...

output:

5222979.434567

result:

ok found '5222979.43457', expected '5222979.43457', error '0.00000'

Test #8:

score: 0
Accepted
time: 6ms
memory: 4388kb

input:

17 84 10513 2
0 84 0.076619 58
0 84 0.031737 100
0 84 0.391032 49
0 84 0.124720 80
61 72 0.445021 85
46 70 0.384419 65
0 84 0.784347 2
0 84 0.458732 81
0 84 0.492603 39
0 84 0.737276 36
71 82 0.515552 24
0 84 0.396508 39
0 84 0.740824 96
0 84 0.077276 29
5 33 0.351774 88
14 71 0.880723 48
0 84 0.601...

output:

1597545.787419

result:

ok found '1597545.78742', expected '1597545.78742', error '0.00000'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3996kb

input:

17 29 386 2
0 29 0.737740 76
0 29 0.883467 32
0 29 0.669514 89
0 29 0.395894 92
2 13 0.102912 93
25 28 0.881119 98
26 28 0.830786 72
3 6 0.435087 72
0 29 0.878533 58
3 29 0.621739 93
5 15 0.284667 34
9 11 0.035538 88
0 29 0.629487 68
0 29 0.238057 19
6 19 0.478706 88
5 17 0.354688 43
0 29 0.417890 8...

output:

81096.245061

result:

ok found '81096.24506', expected '81096.24506', error '0.00000'

Test #10:

score: 0
Accepted
time: 15ms
memory: 5068kb

input:

70 140 28000 19
25 58 0.653969 31
0 140 0.182857 77
0 140 0.525224 35
28 65 0.639027 46
0 140 0.499527 62
0 140 0.972406 15
96 116 0.270799 67
0 140 0.727482 65
0 140 0.404209 25
0 140 0.627591 41
0 140 0.670551 87
0 140 0.262589 2
0 140 0.471431 96
0 140 0.052116 12
0 140 0.999722 82
0 140 0.169518...

output:

14491930.855773

result:

ok found '14491930.85577', expected '14491930.85577', error '0.00000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3912kb

input:

159 316 29 26
83 271 0.017059 34
216 301 0.904438 63
0 316 0.306125 38
0 316 0.389166 13
0 316 0.999879 6
0 316 0.422889 75
185 212 0.397764 99
62 224 0.245311 98
0 316 0.892257 68
0 316 0.889513 45
0 316 0.831260 80
209 260 0.516687 48
130 231 0.705673 41
252 304 0.085931 75
0 316 0.265820 49
0 316...

output:

30324.595746

result:

ok found '30324.59575', expected '30324.59575', error '0.00000'

Test #12:

score: 0
Accepted
time: 6ms
memory: 4356kb

input:

65 108 11576 14
0 108 0.451866 89
102 107 0.214761 5
0 108 0.192549 44
0 108 0.578872 45
97 105 0.775360 67
0 108 0.881926 99
59 99 0.882141 22
0 108 0.187132 73
65 69 0.942326 86
48 49 0.762752 25
0 108 0.485119 60
0 108 0.676118 61
59 84 0.670225 21
0 108 0.472056 47
0 108 0.099137 19
99 104 0.646...

output:

7093870.575326

result:

ok found '7093870.57533', expected '7093870.57533', error '0.00000'

Test #13:

score: 0
Accepted
time: 37ms
memory: 10868kb

input:

200 350 70000 9
0 350 0.183884 25
0 350 0.666381 73
222 264 0.386110 94
0 350 0.152467 65
0 350 0.126505 70
162 267 0.680840 29
0 350 0.980514 18
0 350 0.014300 88
0 350 0.738411 45
0 350 0.802286 90
276 306 0.672604 68
0 350 0.116134 60
0 350 0.695887 63
70 336 0.607653 69
54 158 0.131791 21
347 34...

output:

136183967.921956

result:

ok found '136183967.92196', expected '136183967.92195', error '0.00000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 7132kb

input:

325 1323 1703 15
92 1068 0.298625 32
0 1323 0.324423 55
1168 1171 0.470542 75
1297 1303 0.990520 67
426 494 0.276127 81
491 982 0.132386 79
0 1323 0.497464 2
965 1296 0.070819 5
0 1323 0.074802 96
323 700 0.041861 4
636 1261 0.960248 4
0 1323 0.779401 73
0 1323 0.960543 36
1215 1276 0.840067 46
2 61...

output:

5615622.720511

result:

ok found '5615622.72051', expected '5615622.72051', error '0.00000'

Test #15:

score: 0
Accepted
time: 131ms
memory: 19964kb

input:

400 1515 246437 77
1062 1214 0.407384 66
337 738 0.536780 53
0 1515 0.373759 74
1216 1332 0.871290 44
0 1515 0.526030 5
1080 1285 0.911119 96
339 726 0.097646 20
11 756 0.403407 38
0 1515 0.158337 67
0 1515 0.237887 42
0 1515 0.663084 80
0 1515 0.695652 45
0 1515 0.796680 95
0 1515 0.607661 42
351 9...

output:

806602429.426223

result:

ok found '806602429.42622', expected '806602429.42621', error '0.00000'

Test #16:

score: 0
Accepted
time: 322ms
memory: 53956kb

input:

700 3000 600000 216
300 1744 0.660128 36
1032 2131 0.289201 70
2466 2812 0.181266 77
2407 2515 0.598609 69
794 2169 0.526758 20
0 3000 0.682753 49
0 3000 0.321934 95
1140 3000 0.010431 13
2686 2935 0.336705 98
0 3000 0.171854 46
0 3000 0.873140 87
2179 2308 0.875102 29
2612 2826 0.509095 13
587 1875...

output:

2720992036.705832

result:

ok found '2720992036.70583', expected '2720992036.70583', error '0.00000'

Test #17:

score: 0
Accepted
time: 3ms
memory: 12020kb

input:

380 2760 5995 84
912 2079 0.972465 53
1479 1592 0.541501 57
2506 2607 0.146349 26
0 2760 0.482380 42
0 2760 0.851008 59
0 2760 0.658122 74
0 2760 0.385564 74
1088 2733 0.312128 48
0 2760 0.692512 42
1679 2527 0.612088 15
713 1214 0.508398 33
0 2760 0.826876 10
0 2760 0.481514 13
311 930 0.497921 85
...

output:

16566288.705390

result:

ok found '16566288.70539', expected '16566288.70539', error '0.00000'

Test #18:

score: 0
Accepted
time: 46ms
memory: 12812kb

input:

208 2807 104266 48
0 2807 0.056321 20
53 80 0.425275 99
0 2807 0.295331 23
1822 2535 0.898722 9
2644 2732 0.658761 82
0 2807 0.038219 7
2651 2752 0.447946 98
0 2807 0.561026 58
0 2807 0.815358 66
0 2807 0.725123 9
0 2807 0.712548 70
1733 2227 0.143409 29
0 2807 0.717573 45
371 812 0.886822 34
2163 2...

output:

149006650.846764

result:

ok found '149006650.84676', expected '149006650.84676', error '0.00000'

Test #19:

score: 0
Accepted
time: 427ms
memory: 66300kb

input:

800 4000 800000 174
0 4000 0.348071 61
0 4000 0.052589 27
0 4000 0.989195 7
0 4000 0.073499 94
0 4000 0.976271 99
389 2165 0.269069 85
0 4000 0.808740 2
1099 1566 0.320494 20
2241 3365 0.508396 26
0 4000 0.389506 90
1254 2849 0.609632 33
550 3506 0.586321 33
2162 3625 0.838129 44
0 4000 0.142271 68
...

output:

4695476499.744129

result:

ok found '4695476499.74413', expected '4695476499.74412', error '0.00000'

Test #20:

score: 0
Accepted
time: 94ms
memory: 20728kb

input:

966 1013 199833 237
0 1013 0.405269 95
0 1013 0.754747 12
276 565 0.873558 56
541 594 0.497471 50
444 600 0.990646 16
0 1013 0.207922 25
958 1009 0.761348 84
0 1013 0.248901 80
0 1013 0.217253 50
0 1013 0.638397 5
0 1013 0.450659 97
156 832 0.636354 44
0 1013 0.756271 76
680 815 0.936532 100
0 1013 ...

output:

1522249090.285551

result:

ok found '1522249090.28555', expected '1522249090.28557', error '0.00000'

Test #21:

score: 0
Accepted
time: 111ms
memory: 21076kb

input:

362 2590 212130 51
1124 2194 0.142934 28
0 2590 0.780441 89
1339 1530 0.331780 20
375 1449 0.776129 9
0 2590 0.394966 81
1569 2392 0.639323 77
0 2590 0.651817 75
0 2590 0.187455 99
1679 2011 0.331179 81
0 2590 0.431192 89
0 2590 0.421126 73
329 2459 0.997056 34
0 2590 0.374732 29
0 2590 0.709463 31
...

output:

653978922.452074

result:

ok found '653978922.45207', expected '653978922.45207', error '0.00000'

Test #22:

score: 0
Accepted
time: 540ms
memory: 90252kb

input:

1000 5000 1000000 320
0 5000 0.278156 7
4865 4985 0.300463 48
0 5000 0.907371 8
3610 3862 0.060568 30
0 5000 0.561506 51
0 5000 0.273706 98
2124 3315 0.030748 55
2886 4149 0.647372 31
2104 2361 0.151494 8
0 5000 0.349850 44
1441 2131 0.857740 46
3573 4685 0.980935 15
1784 4302 0.578522 90
3760 4200 ...

output:

6234600845.145258

result:

ok found '6234600845.14526', expected '6234600845.14508', error '0.00000'

Test #23:

score: 0
Accepted
time: 341ms
memory: 53156kb

input:

182 6676 653601 21
3073 3649 0.769162 3
0 6676 0.386859 25
0 6676 0.314518 13
0 6676 0.154438 85
0 6676 0.873264 35
0 6676 0.027007 76
1192 1621 0.420229 48
1551 2236 0.948674 66
120 132 0.262291 87
0 6676 0.487055 70
0 6676 0.663506 27
0 6676 0.205504 22
1249 1405 0.432708 96
4415 6291 0.268584 30
...

output:

1002743652.820967

result:

ok found '1002743652.82097', expected '1002743652.82097', error '0.00000'

Test #24:

score: 0
Accepted
time: 341ms
memory: 77704kb

input:

678 7995 629262 118
5809 6818 0.853051 65
0 7995 0.488050 52
0 7995 0.514459 15
0 7995 0.607582 18
0 7995 0.664549 29
0 7995 0.921158 35
0 7995 0.915150 77
2797 7419 0.872136 93
5338 7498 0.482554 2
4229 6745 0.338630 83
0 7995 0.329523 20
0 7995 0.616744 28
0 7995 0.938165 47
6403 7665 0.533284 89
...

output:

3383681688.273651

result:

ok found '3383681688.27365', expected '3383681688.27357', error '0.00000'

Test #25:

score: 0
Accepted
time: 546ms
memory: 130028kb

input:

1000 10000 1000000 256
2152 9657 0.112740 31
0 10000 0.555674 97
0 10000 0.808830 16
0 10000 0.431068 64
0 10000 0.624134 82
0 10000 0.132537 72
3163 9776 0.263813 59
9018 9700 0.559773 51
4740 7594 0.642697 73
224 2180 0.560118 50
0 10000 0.296010 66
0 10000 0.558466 21
3679 6163 0.081349 29
5330 9...

output:

7212698976.763208

result:

ok found '7212698976.76321', expected '7212698976.76311', error '0.00000'

Test #26:

score: 0
Accepted
time: 39ms
memory: 83344kb

input:

1000 10000 30000 400
3867 3868 0.303299 92
6489 6490 0.478878 11
1089 1090 0.019817 70
4741 4742 0.800452 97
964 965 0.221928 68
5902 5903 0.276683 22
1739 1740 0.261720 3
4264 4265 0.800448 24
2700 2701 0.309850 80
6101 6102 0.086718 77
5528 5529 0.671701 64
4077 4078 0.177790 60
4587 4588 0.089346...

output:

8283.719805

result:

ok found '8283.71981', expected '8283.71981', error '0.00000'

Test #27:

score: 0
Accepted
time: 36ms
memory: 83340kb

input:

1000 10000 30000 400
4185 4186 0.741787 88
8684 8685 0.029005 59
4080 4081 0.648975 20
1854 1855 0.371793 31
6238 6239 0.543761 73
4085 4086 0.013114 27
6687 6688 0.279482 98
6380 6381 0.159604 9
2273 2274 0.617926 56
2075 2076 0.132241 0
3431 3432 0.773594 21
2727 2728 0.289305 25
8834 8835 0.87611...

output:

8039.525126

result:

ok found '8039.52513', expected '8039.52513', error '0.00000'

Test #28:

score: 0
Accepted
time: 550ms
memory: 130396kb

input:

1000 10000 1000000 600
926 1500 0.084872 21
4121 5048 0.605944 77
585 9522 0.681246 55
6447 8340 0.949395 69
7288 8225 0.268241 4
449 5964 0.464894 40
6226 6940 0.891789 67
2694 9183 0.177436 29
390 2895 0.325143 17
8358 8359 0.359691 65
2979 9173 0.995178 57
6793 8607 0.906594 97
5967 9723 0.353787...

output:

486691436.712039

result:

ok found '486691436.71204', expected '486691436.71200', error '0.00000'

Test #29:

score: 0
Accepted
time: 538ms
memory: 130708kb

input:

1000 10000 1000000 600
3898 9709 0.544229 47
7766 9894 0.625720 8
215 9922 0.908818 60
4249 9024 0.234331 91
7704 8863 0.836461 60
2467 6506 0.231922 19
6388 8571 0.741252 85
1049 2611 0.758230 75
701 4935 0.780076 34
7745 9744 0.718824 49
6471 6994 0.728126 73
2197 7284 0.878867 12
587 2227 0.49488...

output:

474448126.187519

result:

ok found '474448126.18752', expected '474448126.18800', error '0.00000'

Test #30:

score: 0
Accepted
time: 540ms
memory: 128648kb

input:

1000 10000 1000000 490
49 9903 0.890244 5
33 9935 0.485928 100
38 9939 0.358049 27
64 9983 0.281838 96
12 9921 0.799403 68
90 9923 0.902166 39
12 9907 0.073742 87
42 9940 0.559814 45
55 9960 0.610887 26
70 9939 0.442693 66
33 9993 0.805028 70
1 9989 0.719705 51
90 9900 0.668153 0
78 9937 0.828063 42...

output:

11177448457.319969

result:

ok found '11177448457.31997', expected '11177448457.30000', error '0.00000'

Test #31:

score: 0
Accepted
time: 544ms
memory: 129980kb

input:

1000 10000 1000000 490
17 9928 0.847434 97
8 9968 0.117919 97
57 9940 0.651593 100
26 9988 0.487857 49
55 9923 0.762280 0
89 9943 0.266331 29
75 9987 0.901427 3
2 9997 0.649546 1
48 9913 0.216599 54
92 9997 0.527629 97
56 9937 0.552860 44
29 9914 0.218781 58
37 9998 0.416180 71
82 9988 0.185906 92
3...

output:

11251894926.641390

result:

ok found '11251894926.64139', expected '11251894926.60000', error '0.00000'