Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这个代码不知道wa哪了,巨巨们能不能找个反例- -#include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <map> #include <iomanip> #include <algorithm> #include <queue> #include <stack> #include <set> #include <vector> //const int maxn = 1e5+5; #define ll long long ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} #define MAX INT_MAX #define FOR(i,a,b) for( int i = a;i <= b;++i) #define bug cout<<"--------------"<<endl using namespace std; struct node { int l,r,sum; }a[1100]; int n,m,R; int dp[1100]; bool cmp(node a,node b) { if(a.l == b.l) return a.r < b.r; return a.l < b.l; } int main() { ios::sync_with_stdio(false); cin>>n>>m>>R; FOR(i,1,m) { cin>>a[i].l>>a[i].r>>a[i].sum; } sort(a+1,a+1+m,cmp); for(int i=1;i<=m;++i) { dp[i] = a[i].sum; for(int j=1;j<i;++j) { dp[i] = max(dp[i], dp[j]); if(a[i].l >= a[j].r + R) dp[i] = max(dp[i], dp[j] + a[i].sum); } } cout<<dp[m]<<endl; // FOR(i,1,m) // cout<<dp[i]<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator