标签:div ++ 坑爹 iostream class std last case art
一个DP,DP还是要靠积累,输出格式略微坑爹
#include <iostream> #include <cstring> using namespace std; int arr[100000+10]; int sum[100000+10]; int start[100000+10]; int main() { int T; cin>>T; int case_t=1; while(T--) { int n; cin>>n; memset(sum,0,sizeof(sum)); memset(start,0,sizeof(start)); for(int i=1;i<=n;i++) { cin>>arr[i]; // sum[i]=sum[i-1]+arr[i]; } // int sum_num=0; // int first,last; start[0]=1; for(int i=1;i<=n;i++) { if(sum[i-1]+arr[i]>=arr[i]) { sum[i]=sum[i-1]+arr[i]; start[i]=start[i-1]; } else { sum[i]=arr[i]; start[i]=i; } } int sum_num=sum[1]; int first=1; int last=1; for(int i=1;i<=n;i++) { if(sum[i]>sum_num) { sum_num=sum[i]; first=start[i]; last=i; } } cout<<"Case "<<case_t++<<":"<<endl; cout<<sum_num<<" "<<first<<" "<<last<<endl; if(T) cout<<endl; } return 0; }
标签:div ++ 坑爹 iostream class std last case art
原文地址:http://www.cnblogs.com/lulichuan/p/6526408.html