QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394210#2536. AkcijaOccDreamer0 24ms63800kbC++142.5kb2024-04-20 10:20:372024-04-20 10:20:38

Judging History

This is the latest submission verdict.

  • [2024-04-20 10:20:38]
  • Judged
  • Verdict: 0
  • Time: 24ms
  • Memory: 63800kb
  • [2024-04-20 10:20:37]
  • Submitted

answer

//OccDreamer
#include<bits/stdc++.h>

#define vc vector
#define db double
#define fi first
#define se second
#define ll long long
#define mk make_pair
#define pb push_back
#define RI register int
#define PI pair<int,int>
#define ull unsigned long long
#define err cerr << "   -_-   " << endl
#define debug cerr << " ------------------- " << endl

#define input(x) freopen(#x".in","r",stdin)
#define output(x) freopen(#x".out","w",stdout)

#define NO puts("No")
#define YES puts("Yes")

//#define OccDreamer
#define int long long

using namespace std;

namespace IO{
	inline int read(){
		int X=0, W=0; char ch=getchar();
		while(!isdigit(ch)) W|=ch=='-', ch=getchar();
		while(isdigit(ch)) X=(X<<1)+(X<<3)+(ch^48), ch=getchar();
		return W?-X:X;
	}
	inline void write(ll x){
		if(x<0) x=-x, putchar('-');
		if(x>9) write(x/10);
		putchar(x%10+'0');
	}
	inline void sprint(ll x){write(x), putchar(32);}
	inline void eprint(ll x){write(x), putchar(10);}
}using namespace IO;

const int MAXN = 2005;

int n, k, pos;

struct P{
	int w, d;
	inline bool friend operator < (const P &x, const P &y){return x.d==y.d?x.w<y.w:x.d<y.d;}
}c[MAXN];

struct dp{
	int num; ll val;	
	inline dp friend operator + (const dp &x, const dp &y){return dp{x.num+y.num,x.val+y.val};}
	inline bool friend operator < (const dp &x, const dp &y){
		return x.num==y.num?x.val<y.val:x.num>y.num;	
	}
}f[MAXN][MAXN];

inline bool comp(dp x, dp y){
	return (x+f[pos+1][x.num])<(y+f[pos+1][y.num]);
}

signed main(){
	n=read(), k=read();
	for(int i=1;i<=n;++i) c[i].w=read(), c[i].d=read();
	sort(c+1,c+1+n);
	for(int i=n;i>=1;--i){
		for(int j=n;j>=0;--j){
			f[i][j]=min(f[i][j],f[i+1][j]); f[i][j]=min(f[i][j+1],f[i][j]);
			if(c[i].d>j) f[i][j]=min(f[i][j],f[i+1][j+1]+dp{1,c[i].w});	
		//cerr << "dp:" << i << ' ' << j << ' ' << f[i][j].num << ' ' << f[i][j].val << endl;
		}
	}
	cout << f[0][0].num << ' ' << f[0][0].val << endl;
	return 0;
	vc<dp> now; now.pb(dp{0,0});
	for(int i=1;i<=n;++i){
		vc<dp> S;
		//cerr << i << ' ' << now[0].num << ' ' << now[0].val << endl;
		for(auto j:now){
			S.pb(j);
			if(c[i].d>j.num) S.pb(dp{j.num+1,j.val+c[i].w});	
		}
		pos=i+1;
		sort(S.begin(),S.end(),comp);
		int o=min((long long)(S.size()),k); now.clear();
		for(int j=0;j<o;++j) now.pb(S[j]);
	}
	sort(now.begin(),now.end());
	for(auto i:now) sprint(i.num), eprint(i.val);
	return 0;
}
/*
9 1
539032129 4
539032129 4
539032130 4
539031219 4
539019129 4
539032129 4
539034123 4
539042939 4
539524354 4
*/

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 24ms
memory: 63800kb

input:

1919 1
126746165 1373
126746165 1621
126746165 1157
126746165 1647
126746165 1046
126746165 1626
126746165 813
126746165 1197
126746165 1240
126746165 738
126746165 840
126746165 571
126746165 1712
126746165 109
126746165 1850
126746165 524
126746165 736
126746165 917
126746165 1520
126746165 1559
1...

output:

0 0

result:

wrong answer 1st lines differ - expected: '1893 239930490345', found: '0 0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #27:

score: 0
Wrong Answer
time: 20ms
memory: 63796kb

input:

1919 2
126746165 1373
668827372 1621
842598033 1157
119717982 1647
527842278 1046
492815129 1626
917098873 813
346103003 1197
144760418 1240
339840086 738
518170881 840
527423104 571
783646464 1712
77685618 109
74284316 1850
300769843 524
944005181 736
969138120 917
789000286 1520
358649048 1559
189...

output:

0 0

result:

wrong answer 1st lines differ - expected: '1893 934318516761', found: '0 0'

Subtask #4:

score: 0
Wrong Answer

Test #40:

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

input:

19 1910
872059530 14
567896598 17
515371564 12
609933207 17
421749461 11
993851818 17
897732743 9
76274388 12
362276371 13
93554371 8
695969254 9
21709341 6
395396341 17
894018749 2
835539456 19
150700500 6
934168428 8
934249073 10
508532761 16

output:

0 0

result:

wrong answer 1st lines differ - expected: '18 9787132136', found: '0 0'

Subtask #5:

score: 0
Wrong Answer

Test #53:

score: 0
Wrong Answer
time: 1ms
memory: 4184kb

input:

96 96
390531470 69
349016804 82
612244127 58
41258987 83
470944790 53
681046579 82
109569778 41
700928268 60
224279712 63
681889278 37
173204769 43
701269722 29
624757038 86
271969787 6
444924884 93
500697380 27
509702566 37
262449977 46
669488879 77
170692294 78
362932916 51
118514404 47
724509790 ...

output:

0 0

result:

wrong answer 1st lines differ - expected: '94 42881894279', found: '0 0'

Subtask #6:

score: 0
Skipped

Dependency #1:

0%