|
|
#include <iostream> using namespace std; int main() { int n,c; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++) if(a[i]<a[j]){c=a[i];a[i]=a[j];a[j]=c;} } c=a[n-1]; for(int i=0;i<n;i++) c=c+a[i]; cout<<c; return 0; } Edited by author 25.03.2022 06:30 give me this test please.. 6 1 3 2 5 4 6 Answer: 27 May be this is not 5th test, but if you can solve this, you'll understand what's wrong in your current solving. :-) Can you explain it to me, how you get 27? Just sort it, before your solution. You can not use sort: ans=a1+...+an+max{a1,..,an} What is the answer for the test case 6 1 3 2 5 4 6 27 why not 29 ? Mine is also 29 I m getting WA#5 with my code +1 Do u have any clue what is test case 5? What's 5 test? Give me this test, please. Edited by author 10.11.2012 14:59 Can we replace places of the bats 29? 27. You can replace the bat. What's 11 test? Give me this test, please. Edited by author 24.04.2013 22:50 Simple try to find the biggest and double it, then find the sum. Good luck. Edited by author 14.02.2013 22:59 What is the logic of this decision? The smallest number of pages is needed if we put skins in the sorted order. Thus the total is the sum plus the largest. |
|
|