QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409392#8641. Ski 2Crysfly0 1234ms11488kbC++172.2kb2024-05-12 00:48:372024-05-12 00:48:39

Judging History

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

  • [2024-05-12 00:48:39]
  • 评测
  • 测评结果:0
  • 用时:1234ms
  • 内存:11488kb
  • [2024-05-12 00:48:37]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
//#define double long double
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 300005
#define inf 0x3f3f3f3f3f3f3f3f

int n,V;
struct node{
	int h,c;
}a[maxn];

int t[maxn],m,sum[maxn],mn[maxn];
#define N 45
int f[N][N],tf[N][N];
vi buc[maxn];

void chkmin(int&x,int y){
	x=min(x,y);
}

signed main()
{
	n=read(),V=read();
	For(i,1,n)a[i].h=read(),a[i].c=read();
	sort(a+1,a+n+1,[&](node x,node y){
		return x.c<y.c;
	});
	For(i,1,n) For(j,0,n-1) t[++m]=a[i].h+j;
	sort(t+1,t+m+1),m=unique(t+1,t+m+1)-t-1;
	#define Val(x) lower_bound(t+1,t+m+1,x)-t
	For(i,1,n) {
		buc[Val(a[i].h)].pb(i);
	}
	memset(f,63,sizeof f);
	
	mn[0]=inf;
	For(i,1,m) {
		sum[i]=sum[i-1]+buc[i].size();
		mn[i]=mn[i-1];
		for(int x:buc[i]) mn[i]=min(mn[i],x);
	}
	
	For(i,1,m) {
		int cnt=buc[i].size();
	//	cout<<"i: "<<i<<" "<<t[i]<<" "<<cnt<<"\n";
		memset(tf,63,sizeof tf);
		int id=mn[i];
		// jiekou meijieshangde min
		For(x,0,n)For(y,0,n) if(f[x][y]<inf) {
		//	cout<<"x,y,z "<<x<<" "<<y<<" "<<z<<" "<<f[x][y][z]<<"\n";
			int nx=x;
			int ny=y+cnt;
			int tmp=min(nx,ny);
			int add=0;
			if(tmp) ny-=tmp,add+=tmp*V*t[i];
			int vals=t[i]*V+a[id].c;
			For(p,0,ny) chkmin(tf[nx+p][ny-p],f[x][y]+vals*p+add);
		}
		if(cnt){
			int u=buc[i][0];
			assert(a[u].h==t[i]);
			chkmin(tf[1][sum[i]-1],t[i]*V);
		}
		swap(tf,f);
	}
	int res=inf;
	For(x,0,n) res=min(res,f[x][0]);
	int ss=0;
	For(i,1,n) res-=a[i].h*V,ss+=a[i].h*V;
//	cout<<"SS "<<ss<<"\n";
	cout<<res;
	return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1234ms
memory: 11372kb

input:

300 987761245
249 97
279 38
52 53
190 2
294 46
170 93
260 70
273 6
49 4
32 71
188 28
212 10
253 86
187 46
167 27
32 75
226 90
86 17
172 24
129 70
291 78
189 98
97 98
256 19
228 36
240 86
240 63
269 21
81 81
41 25
155 49
279 12
176 49
136 25
260 95
271 90
202 79
299 36
79 53
297 59
46 92
202 19
125 3...

output:

-44689282007535

result:

wrong answer 1st lines differ - expected: '144', found: '-44689282007535'

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 637ms
memory: 11488kb

input:

300 1
0 6596366
1 195480684
2 39457151
1 832234727
1 462764495
2 81049898
0 487070027
1 430671894
2 721333033
1 615885993
1 842070560
1 592116125
2 840818824
0 544935711
2 333187430
2 467111553
0 416912849
2 159079860
0 478546939
0 593053374
0 876528192
2 9215174
1 93255151
2 120891934
0 10339332
2 ...

output:

-307

result:

wrong answer 1st lines differ - expected: '44543', found: '-307'

Subtask #3:

score: 0
Wrong Answer

Test #20:

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

input:

10 849097758
4 937762392
10 817247459
0 440668594
1 912982987
7 663812156
7 594886472
0 837105766
2 737473115
3 649275922
10 873042888

output:

1289766352

result:

ok single line: '1289766352'

Test #21:

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

input:

10 9998
5 878445115
0 949971639
4 896709623
3 782518625
0 763551803
2 795919483
10 820305225
7 955019709
0 988957902
6 794013355

output:

89982

result:

ok single line: '89982'

Test #22:

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

input:

10 313931642
1 752682337
6 864853209
7 172291208
3 849996643
9 462903663
3 806832309
7 415016851
7 200488544
2 936575125
4 772486850

output:

924973545

result:

wrong answer 1st lines differ - expected: '1066613979', found: '924973545'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%