제출 #124249

#제출 시각아이디문제언어결과실행 시간메모리
124249amiratouBoat (APIO16_boat)C++14
0 / 100
14 ms4344 KiB
#include <bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define fi first #define se second #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl; #define sep() cerr << "--------------------" << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (ll)x.size() #define ll long long #define int ll #define ii pair<int,int> #define v vector<int> #define vii vector<ii> #define vv vector<vector<int> > #define mp make_pair #define INF 1000000000 #define pb push_back #define EPS 1e-9 const int MOD = 1000000007; // 998244353 int B[501],A[501]; v vec; int n; int dp[501][1005]; int solve(int i,int last){ if(i==n) return 1; //debugs(i,vec[last]) if(dp[i][last]!=-1) return dp[i][last]; int ans=0; if(B[i]>=last){ ans+=solve(i+1,last); if(vec[last]<A[i]) ans=((ans%MOD)+(((B[i]-A[i]+1)*(solve(i+1,lower_bound(all(vec),B[i])-vec.begin())))%MOD))%MOD; else ans=((ans%MOD)+(((((B[i]-A[i])*(B[i]-A[i]+1))/2)*(solve(i+1,lower_bound(all(vec),B[i])-vec.begin())))%MOD))%MOD; } return dp[i][last]=ans%MOD; } main(){ boost; memset(dp,-1,sizeof dp); set<int> myset; cin>>n; for (int i = 0; i < n; ++i) { cin>>A[i]>>B[i]; myset.insert(A[i]); myset.insert(B[i]); } vec.pb(0); for(auto it:myset) vec.pb(it); cout<<solve(0,0); return 0; } //long long //array bounds //special cases //binary search

컴파일 시 표준 에러 (stderr) 메시지

boat.cpp:43:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main(){
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...