Submission #208191

#TimeUsernameProblemLanguageResultExecution timeMemory
208191DodgeBallManBoat (APIO16_boat)C++14
9 / 100
365 ms4500 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...