QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527912#7122. OvertakingRafi229 2ms15928kbC++172.1kb2024-08-22 22:32:162024-08-22 22:32:17

Judging History

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

  • [2024-08-22 22:32:17]
  • 评测
  • 测评结果:9
  • 用时:2ms
  • 内存:15928kb
  • [2024-08-22 22:32:16]
  • 提交

answer

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

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=2000000000000000007;
ll mod=1000000007;
ll mod1=998244353;

const int N=1007;

vector<pair<pair<ll,ll>,int>>V[N];
ll DP[N][N];
int pos[N][N];
ll S[N];
ll X;
int n,m;

void init(int L,int nn,vector<ll>T,vector<int>W,int XX,int mm,vector<int>SS)
{
	X=XX,m=mm;
	FOR(i,0,m-1) S[i]=SS[i];
	FOR(i,0,nn-1) 
	{
		if(W[i]>X)
		{
			V[0].pb({{T[i],W[i]},i});
			n++;
		}
	}
	sort(all(V[0]));
	FOR(i,1,m-1)
	{
		ll mn=infl;
		ROF(j,n-1,0) 
		{
			mn=min(mn,V[i-1][j].st.st+(S[i]-S[i-1])*V[i-1][j].st.nd);
			V[i].pb({{mn,V[i-1][j].st.nd},V[i-1][j].nd});
		}
		sort(all(V[i]));
		FOR(j,0,n-1) pos[i][V[i][j].nd]=j;
	}
	ROF(i,m-1,0)
	{
		FOR(j,0,n-1)
		{
			bool is=0;
			FOR(l,i+1,m-1)
			{
				if(j>0&&V[l][pos[i][V[i][j-1].nd]].st.st>=V[i][j].st.st+(S[l]-S[i])*X)
				{
					DP[i][j]=DP[l][pos[i][V[i][j-1].nd]];
					is=1;
					break;
				}
			}
			if(!is) DP[i][j]=V[i][j].st.st+(S[m-1]-S[i])*X;
			debug(i,j,V[i][j].st.st,V[i][j].st.nd,DP[i][j]);
		}
	}
    return;
}

ll arrival_time(ll Y)
{
	/*ll ans=Y+(S[m-1]-S[0])*X;
	FOR(j,0,n-1) if(Y>V[0][j].st) ans=max(ans,V[0][j].st+V[0][j].nd*(S[m-1]-S[0]));
	return ans;*/
	ROF(j,n-1,0)
	{
		if(Y>V[0][j].st.st) 
		{
			debug(j,V[0][j].st.st,V[0][j].st.nd);
			FOR(i,1,m-1)
			{
				if(V[i][pos[i][V[0][j].nd]].st.st>=Y+(S[i]-S[0])*X) 
				{
					debug(i);
					return DP[i][j];
				}
			}
			break;
		}
	}
	return Y+(S[m-1]-S[0])*X;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 9
Accepted

Test #1:

score: 9
Accepted
time: 0ms
memory: 10188kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
2500 1 78 100 1000
100000
80
0 38 51 89 92 105 117 119 122 126 142 179 259 355 385 410 419 443 483 496 551 671 691 698 709 762 778 818 860 888 897 909 930 938 946 951 955 995 1045 1091 1164 1187 1215 1243 1264 1301 1363 1409 1416 1448 1504 1518 1535 1555 1562 1597 16...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
299664
298224
299166
298008
295102
298070
297182
298650
298312
296396
296524
298070
295838
296910
296892
297374
298684
295184
295710
299062
296382
298684
298110
298008
299530
298766
295966
299062
296794
298998
299738
296418
298588
296876
295102
299860
295710
29577...

result:

ok 

Test #2:

score: 9
Accepted
time: 2ms
memory: 12656kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
80000001 1 151251000 400 1000
10000
151251252
0 563193 647572 715146 1130358 1138744 1557704 2110181 2300143 2420378 2557533 2614949 2657752 2838017 2861875 3146425 3202178 3240281 3248583 3280296 3310987 3401711 3683587 3943976 4135364 4214616 4277932 4503844 476465...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
12100095744014512
12100080944160100
12100085508223828
12100095197505388
12100090627084960
12100097311519276
12100080683026612
12100093846636708
12100099968098740
12100096796223124
12100096142019784
12100097662974856
12100083572845936
12100099936140100
121000877792...

result:

ok 

Test #3:

score: 9
Accepted
time: 0ms
memory: 15652kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
700000000 1 199 800 1000
2000
200
0 2547880 2899696 3746196 5005561 5262711 7391315 7766094 8058134 12302379 14113798 14139018 16263685 19246991 20293858 21308475 21531629 21609437 22819772 23818245 23866117 24082599 24830023 25092620 25219376 27345462 27398799 28906...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
139981678448
139714673517
139493728857
139777641660
139908912147
139434676500
139585452046
139704974839
139718370512
139701821327
139448528458
139463864882
139927337590
139754511858
139416197864
139844650005
139808181948
139577750390
139643626646
139688190761
1396...

result:

ok 

Test #4:

score: 9
Accepted
time: 0ms
memory: 14816kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
1000000000 1 99 1000 1000
1000000000000
100
0 1817308 2789727 3514387 5238876 5972281 7743105 8541339 9248161 10089380 11281389 11329343 14077050 14155477 16510318 19268709 19528706 19612683 19893513 20400622 21278533 21582205 24880066 27530395 27569486 28339765 2922...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
1099248330619
1099325193168
1099666752580
1099563034876
1099525957106
1099785654428
1099996241055
1099847005338
1099823366993
1099082743936
1099501468836
1099332698857
1099168227471
1099262165670
1099409777071
1099821586703
1099761464774
1099878195061
109999213744...

result:

ok 

Test #5:

score: 9
Accepted
time: 0ms
memory: 15928kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
1000000000 1 880000000 1000 1000
100000000000000000
880001000
0 709332 1017351 1905741 3045292 3464378 3632596 5704941 6735246 9747846 10704021 12434640 13264129 14081255 14176931 15634238 17365369 18691988 19399867 20069605 21121920 23160840 23345820 24551706 255281...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
980000473593602000
980000328241893000
980000496751131000
980000100732727000
980000460850951000
980000615531582000
980000605439144000
980000435818946000
980000696831126000
980000166079150000
980000940725540000
980000805086273000
980000698057886000
98000016833636000...

result:

ok 

Test #6:

score: 9
Accepted
time: 0ms
memory: 15652kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 498 1000 1000
100000000000000000
500
0 160783 205816 346327 347823 367191 395170 441295 639474 718881 831118 875863 1298479 1319125 1431282 1514976 1596686 1644592 1644648 1671765 1680769 1760215 1869745 1989596 2020399 2106354 2289587 2488522 2594930 272...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000049926232916
100000049864514052
100000049973025928
100000049995005458
100000049930515196
100000049843074864
100000049920623428
100000049897187068
100000049802862564
100000049946008956
100000049946867894
100000049917050904
100000049822989734
10000004993122233...

result:

ok 

Test #7:

score: 9
Accepted
time: 1ms
memory: 3824kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 401 1000 1000
100000000000000000
400
0 31311 143468 183347 233725 256130 444842 481905 486233 527809 549435 664450 1549723 1573249 1619077 1673590 1911655 1913292 2059722 2158189 2259116 2349409 2426923 2437811 2474156 2510525 2528753 2614955 2695324 2871...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000040105826882
100000040124582713
100000040181245022
100000040169641106
100000040135428053
100000040137403238
100000040172575752
100000040194573555
100000040163594943
100000040110810308
100000040187649357
100000040116517222
100000040114627594
10000004013557963...

result:

ok 

Test #8:

score: 9
Accepted
time: 1ms
memory: 5864kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
10 1 5 5 10
0
6
0 2 8 9 10
9
2
4
5
0
1
2
3
10
20

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
59
52
58
58
50
52
52
58
60
70

result:

ok 

Test #9:

score: 9
Accepted
time: 0ms
memory: 10288kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
1000000000 1 880000000 100 100
100000000000000000
880001000
0 18125472 18662947 20132713 38844162 50912725 59000193 70694095 79014902 84781895 107240650 124792182 125767204 150665436 158106715 162875579 169664865 184892442 192426843 210142654 221584689 224390935 2398...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
980000939022239000
980000210142654000
980000989457694000
980000307752813000
970286252078123694
980000000000000000
980000902460888000
980000434973267000
980000906339786000
980000526408935000
980000282731536000
980000434973267000
980000210142654000
98000016966486500...

result:

ok 

Test #10:

score: 9
Accepted
time: 1ms
memory: 6524kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 498 100 100
100000000000000000
500
0 829700 1359408 1753928 1877428 2734456 2977184 3054027 3673453 4432770 5771214 5906467 8822394 10489610 11221287 11534731 16500729 19052276 19320520 20664138 20737902 22046077 23121119 29574967 29854061 30109803 304197...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000049863849700
100000049962684802
100000049805468912
100000049838104552
100000049869485964
100000049879617250
100000049817644788
100000049913581290
100000049862347240
100000049869319444
100000049995389460
100000049802718816
100000049928978048
10000004992176166...

result:

ok 

Test #11:

score: 9
Accepted
time: 0ms
memory: 3884kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 401 100 100
100000000000000000
400
0 1310416 2393682 2579012 3615394 6750570 6794866 6934895 7799665 8347376 8621879 9284983 10987581 12631682 14785700 15715498 16575943 17379309 18460496 18774602 19006189 20255533 22914625 23446266 25870132 26382507 2818...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000040195912004
100000040167926330
100000040172845150
100000040194544782
100000040108588211
100000040142271715
100000040141179703
100000040108392021
100000040123135941
100000040177546716
100000040116164403
100000040118375302
100000040115008407
10000004017282049...

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 5884kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
2000000 100 100 2 1000
566035866 424023571 564031634 266012245 266012901 566037245 106005324 106003684 266012594 424028440 424019007 106005224 564034079 424024371 424024546 566039191 424016814 424029581 82000890 754044052 566036512 424018510 424017279 424019925 42401...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
767857455
766915337
1015331273
308008207
766915337
766915337
844481593
766915337
956041170
766915337
766915337
308008207
844481593
308008207
766915337
767857455
1015331273
418008550
766915337
463456653
308008207
1015331273
767857455
766915337
468010817
766915337
6...

result:

wrong answer 3rd lines differ - on the 1st token, expected: '768035150', found: '767857455'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%