BZOJ2697: 特技飛行

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   ar   for   

2697: 特技飛行Time Limit: 10 Sec  Memory Limit: 256 MB
Submit: 607  Solved: 363
[Submit][Status]Description

神犇航空開展了一項載客特技飛行業務。每次飛行長N個單位時間,每個單位時間可以進行一項特技動作,可選的動作有K種,每種動作有一個刺激程度Ci。如果連續進行相同的動作,乘客會感到厭倦,所以定義某次動作的價值為(距上次該動作的時間)*Ci,若為第一次進行該動作,價值為0。安排一種方案,使得總價值最大。

Input  第一行,兩個數,N和K,如上所述;
  第二行,K個正整數,表示K種動作的Ci值。
Output  僅一行,一個整數,表示最大總價值。
Sample Input5 2
2 2

Sample Output12

HINT

資料規模及約定

  對於10%的測試資料,N<=20,K<=3

  對於全部的測試資料,1<=N<=1000,1<=K<=300,0<=Ci<=1000。

Source

題解:

剛開始以為是網路流?後來想了想放棄了。。。

想了想貪心,把大的放到兩端?貌似正確,好像又不嚴密,不敢寫,看看題解吧。。。

。。。。。。

感覺不會再愛了

代碼:

 1 #include<cstdio> 2  3 #include<cstdlib> 4  5 #include<cmath> 6  7 #include<cstring> 8  9 #include<algorithm>10 11 #include<iostream>12 13 #include<vector>14 15 #include<map>16 17 #include<set>18 19 #include<queue>20 21 #include<string>22 23 #define inf 100000000024 25 #define maxn 500026 27 #define maxm 500+10028 29 #define eps 1e-1030 31 #define ll long long32 33 #define pa pair<int,int>34 35 #define for0(i,n) for(int i=0;i<=(n);i++)36 37 #define for1(i,n) for(int i=1;i<=(n);i++)38 39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)40 41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)42 43 #define mod 100000000744 45 using namespace std;46 47 inline int read()48 49 {50 51     int x=0,f=1;char ch=getchar();52 53     while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}54 55     while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}56 57     return x*f;58 59 }60 int n,m,k,a[maxn];61 inline bool cmp(int x,int y)62 {63     return x>y;64 }65 66 int main()67 68 {69 70     freopen("input.txt","r",stdin);71 72     freopen("output.txt","w",stdout);73 74     n=read();k=read();75     for1(i,k)a[i]=read();76     sort(a+1,a+k+1,cmp);77     int ans=0;78     for1(i,min(k,n/2))ans+=(n-2*i+1)*a[i];79     cout<<ans<<endl;80 81     return 0;82 83 }
View Code

 

BZOJ2697: 特技飛行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.