锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
DP鏂圭▼錛歭en[ i ][ j ] = max{ len[ i-1][ j ], len[ i ][ j-1], len[ i+1][ j ], len[ i ][ j+1] };
浠g爜濡備笅錛?br>
#include <iostream>
2
using namespace std;
3
4
int node[102][102];
5
int len[102][102];
6
int r, c;
7
int getLength( int i, int j )
8
{
9
if( len[i][j] > 0 )
10
return len[i][j];
11
int max = 0;
12
if( i + 1 <= r && node[i][j] > node[i+1][j] ){
13
int x = getLength( i + 1, j ) + 1;
14
if( max < x )
15
max = x;
16
}
17
if( j + 1 <= c && node[i][j] > node[i][j+1] ){
18
int x = getLength( i, j + 1 ) + 1;
19
if( max < x )
20
max = x;
21
}
22
if( i - 1 > 0 && node[i][j] > node[i-1][j] ){
23
int x = getLength( i - 1, j ) + 1;
24
if( max < x )
25
max = x;
26
}
27
if( j - 1 > 0 && node[i][j] > node[i][j-1] ){
28
int x = getLength( i, j - 1 ) + 1;
29
if( max < x)
30
max = x;
31
}
32
return max;
33
34
}
35
int main()
36
{
37
38
cin >> r >> c;
39
for ( int i = 1; i <= r; ++i ){
40
for ( int j = 1; j <= c; ++j ){
41
cin >> node[i][j];
42
len[i][j] = 0;
43
}
44
}
45
int maxLen = 0;
46
for( int i = 1; i <= r; ++i ){
47
for( int j = 1; j <= c; ++j ){
48
len[i][j] = getLength( i, j );
49
if( maxLen < len[i][j] )
50
maxLen = len[i][j];
51
}
52
}
53
cout << maxLen + 1<<endl;
54
system( "pause" );
55
}
56
姹?涓縐嶉夋嫨鏂規浣緽/P 鏈澶?nbsp; 鍏朵腑 B鏄悇涓儴浠禸andwith鐨勬渶灝忓?nbsp; P鏄悇涓儴浠秔rice鐨勫拰
鎴戠殑鍋氭硶錛?br>灝哹andwith鎺掑簭錛岀劧鍚庡垎鍒互姣忎竴涓猙andwith鏈涓烘渶灝忓兼椂 姹傚嚭鍙彇鏂規涓璸rice鍊兼渶灝忕殑 閭d釜錛堝嵆 浣緽/P鏈澶э級
鐒跺悗緇煎悎璧鋒潵 姹傛渶澶х殑B/P
涓嬮潰鏄垜鐨勪唬鐮侊細
铏界劧AC浜嗭紝浣嗘槸榪樻槸鏈変竴鐐圭枒鎯戯紝鍦ㄦ煇涓minBand涓烘渶灝忓兼椂錛屾墍鍙栧緱鏂規涓偗瀹氬寘鍚竴涓駭鍝侀夋嫨鐨刡andwith = minBand錛屽惁鍒欐渶灝忓間笉鏄痬inBand錛屼絾鏄垜娌℃湁鍋氳繖涓垽鏂?/p>
浠g爜濡備笅錛屼粎浣滃弬鑰冿細
#include <iostream>
2
#include <set>
3
#include <algorithm>
4
using namespace std;
5
6
struct Device
7
{
8
int nChoice;
9
int quality[102][2];
10
};
11
12
int main()
13
{
14
int ncase;
15
cin >> ncase;
16
while ( ncase-- ){
17
18
int n;
19
double ratio = 0;
20
set <int> intSet;
21
set <int>::iterator sp;
22
cin >> n;
23
Device *s = new Device[n];
24
25
for( int i = 0; i < n; i++ ) {
26
cin >> s[i].nChoice;
27
for( int j = 0; j < s[i].nChoice; j++ ){
28
cin >> s[i].quality[j][0] >> s[i].quality[j][1];
29
intSet.insert( s[i].quality[j][0] );
30
}
31
}
32
33
for( sp = intSet.begin(); sp != intSet.end(); sp++ ){
34
int totalPrice = 0;
35
int minBand = *sp;
36
for( int i = 0; i < n; i++){//閫夋瘡涓縐嶄駭鍝?br>37
int min = 100000;
38
for( int j = 0; j < s[i].nChoice; j++ ){
39
if( s[i].quality[j][0] >= minBand && min > s[i].quality[j][1] )
40
min = s[i].quality[j][1];
41
}
42
totalPrice += min;
43
}
44
if( ratio < (double) (minBand) / (double) totalPrice ){
45
ratio = (double) (minBand) / (double) totalPrice;
46
}
47
}
48
printf( "%.3lf\n", ratio );
49
50
delete s;
51
}
52
system("pause");
53
return 0;
54
}
55
涓寮濮嬶紝鎴戝啓鐨勬槸min = s[i].quality[0][1];寮勪簡濂戒箙閮戒笉鐭ラ亾鍝噷閿欎簡錛屽悗鏉ュ彂鐜板師鏉ョ涓涓笉涓瀹氬彇錛岃繖涓仛姣忔閮絫oalPrice閮芥槸涓鏍風殑....鏍囧嚭鏉ワ紝璀︾ず鑷繁涓涓嬶紝鍛靛懙 浼拌 澶у閮芥病鏈夐敊鐨勮繖涔堢櫧鐥寸殑 >_<