QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#838426#8768. Arrested DevelopmentthunoproRE 5ms11216kbC++141.3kb2024-12-31 10:36:402024-12-31 10:36:42

Judging History

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

  • [2024-12-31 10:36:42]
  • 评测
  • 测评结果:RE
  • 用时:5ms
  • 内存:11216kb
  • [2024-12-31 10:36:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std; 
#define ll long long 
#define maxn 500009 
#define fi first 
#define se second 
#define pb push_back 
#define re exit(0);

const int mod = 1e9+7 ; 
const int INF = 1e9 ; 

typedef vector<int> vi ; 
typedef pair<int,int> pii ;
typedef vector<pii> vii ;  

template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; } ; 
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; } ; 
void runfile () 
{
    freopen ("inp.txt","r",stdin) ; 
}

int n ; 
int dp [2][maxn] ;
int a [maxn] , b [maxn] ; 
int main() 
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0);cout.tie(0) ; 
//    runfile() ;     
    cin >> n ; 
    const int N = 1e5 * n  ;  
    for ( int i = 1 ; i <= n ; i ++ ) cin >> a [i] >> b [i] ; 
    
    memset ( dp , 0x3f , sizeof dp ) ; 
    
    dp [0][0] = 0 ; 
    
    for ( int i = 1 ; i <= n ; i ++ ) 
    {
    	for ( int j = 0 ; j <= N ; j ++ ) 
    	{
    		if ( j + a [i] <= N ) chkmin (dp[1][j+a[i]],dp[0][j]) ; 
    		chkmin (dp[1][j],dp[0][j]+b[i]) ; 
		}
		for ( int j = 0 ; j <= N ; j ++ ) dp [0][j] = dp [1][j] , dp [1][j] = INF ; 
	}
	
	int res = INF ;
	for ( int i = 0 ; i <= N ; i ++ ) chkmin (res,max(i,dp[0][i])) ; 
	cout << res ; 
}

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 10612kb

input:

4
100 1
1 90
1 20
1 20

output:

3

result:

ok single line: '3'

Test #2:

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

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

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

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 2ms
memory: 10596kb

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 2ms
memory: 9424kb

input:

1
1 100000

output:

1

result:

ok single line: '1'

Test #6:

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

input:

1
100000 100000

output:

100000

result:

ok single line: '100000'

Test #7:

score: -100
Runtime Error

input:

50
78681 95291
22639 1538
12119 52253
50430 63757
66133 92826
61048 40069
33506 30382
96049 50134
42895 62735
86943 16955
9667 61843
49647 9320
29082 16909
69601 68436
19892 34306
29822 79462
73262 14568
1693 35040
89757 61888
56993 48750
89611 77773
54159 21067
32520 41091
52501 92770
36530 17589
5...

output:


result: