QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#665908#8354. T2forest1145140 177ms43436kbC++203.0kb2024-10-22 15:49:022024-10-22 15:49:07

Judging History

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

  • [2024-10-22 15:49:07]
  • 评测
  • 测评结果:0
  • 用时:177ms
  • 内存:43436kb
  • [2024-10-22 15:49:02]
  • 提交

answer

//蒟蒻一枚 rp++
//即得易见平凡,仿照上例显然。留作习题答案略,读者自证不难
//反之亦然同理,推论自然成立,略去过程Q.E.D.,由上可知证毕
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
#define re register
#define il inline
#define gc() getchar()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define repp(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define tep(i,x) for(int i=head[x];~i;i=ne[i])
#define ls(x) x<<1
#define rs(x) x<<1|1
#define eps (1e-9)
#define inf 0x3f3f3f3f
#define INF 1e16
#define pii pair<int,int>
#define mp(i,j) make_pair(i,j)
#define pb push_back
#define fi first
#define sc second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef double db;
namespace IO{
//	#define gc()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<9,stdin),p1==p2)?EOF:*p1++)
//	char buf[1<<9],*p1=buf,*p2=buf;
	template<typename T> inline void read(T &x){
		bool f=1;x=0;char ch=gc();
		while(ch<'0'||ch>'9'){if(ch=='-')f=0;ch=gc();}
		while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch&15),ch=gc();
		x=f?x:-x;
	}
	template<typename T> inline void write(T x){
		if(x<0) putchar('-'),x=-x;
	   	if(x>9) write(x/10);
	   	putchar(char('0'+x%10));
	}
	template <typename T,typename ...Args> inline
	void read(T &x,Args &...args){read(x);read(args...);}
	template<typename T> inline void write(T x,char c){write(x),putchar(c);}
}
using namespace IO;
namespace MOD{
	typedef uint32_t u32;
	typedef uint64_t u64;
	typedef __uint128_t u128;
	u64 p,m;
	void set_mod(u32 mod){
		m=mod,p=-m/m+1;
	}
	u64 mo(u64 x){//取模优化
		x-=u64((u128)x*p>>64)*m;
		return (x>=m)?x-m:x;
	}
}
bool _ST;
const int N=2e6+100,B=200;
int n,m,k,v[N],w[N],x[N];
int opt[N],val[N];
int ans[N],f[N],g[N];
bool vis[N];
bool _ED;
signed main(){
	fprintf(stderr,"%.20lf MB\n",(&_ST-&_ED)/1048576.0);
	//ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,m,k);
	memset(v,-inf,sizeof v);
	rep(i,1,n){
		read(x[i]);
		read(v[x[i]]),w[x[i]]=v[x[i]]*x[i],vis[x[i]]=1;
	}
	rep(i,1,m){
		read(opt[i],val[i]);
		if(opt[i]==1) vis[x[val[i]]]=0;
	}
	per(i,k,B+1){
		if(vis[i]){
			per(j,k/i,v[i]) g[j]=max(g[j],g[j-v[i]]+w[i]);
		}
	}
	rep(i,1,B){
		if(vis[i]){
			per(j,k,w[i]) f[j]=max(f[j],f[j-w[i]]+v[i]);
		}
	}
	per(i,m,1){
		if(opt[i]==1){
			int pos=x[val[i]];
			if(pos<=B){
				per(j,k,w[pos]) f[j]=max(f[j],f[j-w[pos]]+v[pos]);
			}
			else{
				per(j,k/B,v[pos]) g[j]=max(g[j],g[j-v[pos]]+w[pos]);
			}
		}
		else{
			int res=0;
			rep(j,0,k/B) if(g[j]<=val[i])res=max(res,f[val[i]-g[j]]+j);
			ans[i]=res;
		}
	}
	rep(i,1,m) if(opt[i]==2) write(ans[i],'\n');
	fprintf(stderr,"%.4lf s\n",1.0*clock()/CLOCKS_PER_SEC);
	return 0;
}
//谨记:
//十年OI一场空,不开longlong见祖宗
//数据千万条,清空第一条。多测不清空,爆零两行泪。清空不规范,TLE总相伴。
//快读要加类型名


詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

3205 5000 5000
1 1
2 1
3 1
7 1
8 1
9 1
10 1
11 1
12 2
13 1
14 2
16 1
17 2
20 3
22 1
24 1
26 2
27 1
30 1
32 2
33 1
34 1
41 1
44 2
49 2
51 1
54 2
58 2
61 2
65 2
66 1
68 2
70 1
71 2
72 2
74 8
75 3
76 5
77 1
78 7
79 5
80 5
81 1
82 2
84 1
86 6
87 6
88 3
89 9
90 5
91 1
92 2
93 3
95 7
96 2
97 2
98 8
99 8
1...

output:

81
69
32
40
42
90
32
83
44
50
91
70
53
65
82
50
68
59
86
38
67
70
79
45
50
65
88
43
37
74
29
63
73
7
53
57
75
20
44
50
47
36
73
55
30
42
78
75
47
80
66
87
36
21
73
23
88
37
68
53
57
28
46
59
56
69
28
84
26
41
64
59
35
60
5
42
35
74
63
54
87
73
83
59
39
38
45
48
89
69
62
23
82
84
31
85
56
87
81
80
66...

result:

wrong answer 2047th lines differ - expected: '51', found: '50'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 177ms
memory: 43436kb

input:

1277351 1 2000000
2 2
5 1
7 3
8 4
10 1
12 1
15 2
16 1
18 1
22 1
25 1
28 3
29 1
32 1
35 1
36 1
38 2
40 1
41 2
42 1
43 2
44 2
45 1
48 1
49 1
50 2
54 2
55 2
56 1
58 2
59 2
60 2
62 1
66 1
68 3
69 1
70 3
72 2
76 1
78 1
79 2
81 2
82 3
84 2
85 1
86 2
89 1
90 2
91 2
92 1
93 1
96 3
98 3
99 2
100 3
101 1
102 ...

output:

10171

result:

wrong answer 1st lines differ - expected: '1771', found: '10171'

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 166ms
memory: 27856kb

input:

5000 5000 2000000
1 1
2 1
3 1
4 1
6 1
7 1
8 1
9 1
10 1
11 1
14 1
15 3
17 2
18 2
21 1
22 1
24 1
25 3
27 1
28 2
29 1
30 1
31 1
32 1
33 1
34 1
35 1
37 1
38 1
39 1
40 2
41 2
43 1
45 1
47 1
49 1
50 1
51 1
54 1
55 1
56 1
61 1
62 2
64 1
65 1
67 2
68 2
70 2
72 2
74 1
76 3
79 2
82 4
83 2
84 1
88 1
91 1
92 1
...

output:

172
172
172
172
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
164
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
169
...

result:

wrong answer 1st lines differ - expected: '1778', found: '172'

Subtask #4:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 29ms
memory: 17576kb

input:

191299 5000 300000
1 1
5 1
6 2
7 1
8 1
10 1
11 2
12 2
17 1
18 1
19 1
20 1
21 1
22 2
25 1
28 1
29 2
30 1
31 2
34 1
36 1
37 1
38 1
40 1
42 1
43 1
44 1
45 1
47 2
48 1
51 1
53 3
54 2
56 2
58 2
59 2
61 2
63 4
64 2
67 1
68 2
69 2
70 1
72 1
76 1
77 1
78 1
80 2
83 1
84 1
87 1
88 1
89 1
91 2
93 1
95 1
96 1
9...

output:

160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
128
160
160
160
160
160
160
160
160
160
98
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
140
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
160
1...

result:

wrong answer 1st lines differ - expected: '221', found: '160'

Subtask #5:

score: 0
Wrong Answer

Test #41:

score: 0
Wrong Answer
time: 177ms
memory: 34756kb

input:

1278949 5000 2000000
4 1
9 1
12 1
13 1
15 2
20 1
21 2
26 1
36 1
39 2
43 1
46 2
59 1
64 1
66 1
71 1
73 1
75 1
78 2
83 1
87 1
89 1
92 1
97 1
103 1
104 1
108 1
111 1
113 1
114 1
117 2
118 1
130 1
137 1
140 1
151 1
152 1
155 1
158 2
163 1
164 1
165 1
168 1
172 1
173 1
183 1
185 1
186 1
192 1
208 1
210 2...

output:

56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
56
...

result:

wrong answer 1st lines differ - expected: '272', found: '56'