# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
208191 |
2020-03-10T08:30:29 Z |
DodgeBallMan |
Boat (APIO16_boat) |
C++14 |
|
365 ms |
4500 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 10;
const long long mod = 1e9 + 7;
int n;
long long dp[N][2*N], a[N], b[N];
vector<long long> coord;
long long solve( int pos, long long mi ) {
if( pos > n ){
if( mi == 0 ) return 0;
else return 1;
}
//printf("%d %lld\n",pos,mi);
long long &ret = dp[pos][mi];
if( ret != -1 ) return ret;
ret = 0;
ret = ( ret + solve( pos+1, mi ) ) % mod;
if( mi < a[pos] ) ret = ( ret + solve( pos+1, a[pos] ) ) % mod;
for( int i = max( a[pos] + 1, mi + 1 ) ; i <= b[pos] ; i++ ) ret = ( ret + ( coord[i] - coord[i-1] ) * solve( pos+1, i ) ) % mod;
//printf("%lld\n",ret);
return ret % mod;
}
int main()
{
memset( dp, -1, sizeof dp );
scanf("%d",&n);
coord.emplace_back( 0LL );
for( int i = 1 ; i <= n ; i++ ) {
scanf("%lld %lld",&a[i],&b[i]);
coord.emplace_back( a[i] ), coord.emplace_back( b[i] );
}
sort( coord.begin(), coord.end() );
coord.resize( unique(coord.begin(), coord.end() ) - coord.begin());
for( int i = 1 ; i <= n ; i++ ) {
a[i] = lower_bound( coord.begin(), coord.end(), a[i] ) - coord.begin();
b[i] = lower_bound( coord.begin(), coord.end(), b[i] ) - coord.begin();
}
printf("%lld",solve( 1, 0LL ));
return 0;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
boat.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld",&a[i],&b[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4472 KB |
Output is correct |
2 |
Correct |
9 ms |
4472 KB |
Output is correct |
3 |
Correct |
9 ms |
4472 KB |
Output is correct |
4 |
Correct |
9 ms |
4472 KB |
Output is correct |
5 |
Correct |
9 ms |
4472 KB |
Output is correct |
6 |
Correct |
8 ms |
4472 KB |
Output is correct |
7 |
Correct |
10 ms |
4480 KB |
Output is correct |
8 |
Correct |
9 ms |
4476 KB |
Output is correct |
9 |
Correct |
9 ms |
4472 KB |
Output is correct |
10 |
Correct |
9 ms |
4472 KB |
Output is correct |
11 |
Correct |
9 ms |
4472 KB |
Output is correct |
12 |
Correct |
9 ms |
4472 KB |
Output is correct |
13 |
Correct |
9 ms |
4476 KB |
Output is correct |
14 |
Correct |
8 ms |
4472 KB |
Output is correct |
15 |
Correct |
9 ms |
4452 KB |
Output is correct |
16 |
Correct |
8 ms |
4468 KB |
Output is correct |
17 |
Correct |
7 ms |
4472 KB |
Output is correct |
18 |
Correct |
8 ms |
4472 KB |
Output is correct |
19 |
Correct |
8 ms |
4472 KB |
Output is correct |
20 |
Correct |
7 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4472 KB |
Output is correct |
2 |
Correct |
9 ms |
4472 KB |
Output is correct |
3 |
Correct |
9 ms |
4472 KB |
Output is correct |
4 |
Correct |
9 ms |
4472 KB |
Output is correct |
5 |
Correct |
9 ms |
4472 KB |
Output is correct |
6 |
Correct |
8 ms |
4472 KB |
Output is correct |
7 |
Correct |
10 ms |
4480 KB |
Output is correct |
8 |
Correct |
9 ms |
4476 KB |
Output is correct |
9 |
Correct |
9 ms |
4472 KB |
Output is correct |
10 |
Correct |
9 ms |
4472 KB |
Output is correct |
11 |
Correct |
9 ms |
4472 KB |
Output is correct |
12 |
Correct |
9 ms |
4472 KB |
Output is correct |
13 |
Correct |
9 ms |
4476 KB |
Output is correct |
14 |
Correct |
8 ms |
4472 KB |
Output is correct |
15 |
Correct |
9 ms |
4452 KB |
Output is correct |
16 |
Correct |
8 ms |
4468 KB |
Output is correct |
17 |
Correct |
7 ms |
4472 KB |
Output is correct |
18 |
Correct |
8 ms |
4472 KB |
Output is correct |
19 |
Correct |
8 ms |
4472 KB |
Output is correct |
20 |
Correct |
7 ms |
4472 KB |
Output is correct |
21 |
Incorrect |
365 ms |
4500 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4472 KB |
Output is correct |
2 |
Correct |
9 ms |
4472 KB |
Output is correct |
3 |
Correct |
9 ms |
4472 KB |
Output is correct |
4 |
Correct |
9 ms |
4472 KB |
Output is correct |
5 |
Correct |
9 ms |
4472 KB |
Output is correct |
6 |
Correct |
8 ms |
4472 KB |
Output is correct |
7 |
Correct |
10 ms |
4480 KB |
Output is correct |
8 |
Correct |
9 ms |
4476 KB |
Output is correct |
9 |
Correct |
9 ms |
4472 KB |
Output is correct |
10 |
Correct |
9 ms |
4472 KB |
Output is correct |
11 |
Correct |
9 ms |
4472 KB |
Output is correct |
12 |
Correct |
9 ms |
4472 KB |
Output is correct |
13 |
Correct |
9 ms |
4476 KB |
Output is correct |
14 |
Correct |
8 ms |
4472 KB |
Output is correct |
15 |
Correct |
9 ms |
4452 KB |
Output is correct |
16 |
Correct |
8 ms |
4468 KB |
Output is correct |
17 |
Correct |
7 ms |
4472 KB |
Output is correct |
18 |
Correct |
8 ms |
4472 KB |
Output is correct |
19 |
Correct |
8 ms |
4472 KB |
Output is correct |
20 |
Correct |
7 ms |
4472 KB |
Output is correct |
21 |
Incorrect |
365 ms |
4500 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |