제출 #961595

#제출 시각아이디문제언어결과실행 시간메모리
961595IUA_Hasin휴가 (IOI14_holiday)C++17
0 / 100
8 ms1116 KiB
#include"holiday.h" #include <bits/stdc++.h> #define endl "\n" #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define ll long long using namespace std; const ll N = 100; ll vis[N]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll sum = 0; for(int i=0; i<n; i++){ sum = sum+attraction[i]; } if(start==0){ if(d>=(2*n-1)){ return sum; } else if(d<=2){ ll ans = attraction[0]; if(d==0){ return 0; } else { return ans; } } else { ll a = min(d-1, n-1); ll b; if(d%2==0){ b = d/2; } else { b = floor(d/2)+1; } b--; for(int i=0; i<b; i++){ ll a = attraction[i]; vis[a]++; } ll ans1 = 0; for(int i=b; i<=a; i++){ ll a = attraction[i]; ll extr = d-i-1; ll ans = 0; for(int i=100; i>=0; i--){ if(vis[i]>0){ if(extr<=vis[i]){ ans = ans+i*extr; break; } else { ans = ans+i*vis[i]; extr = extr-vis[i]; } } } ans = ans+attraction[i]; // cout<<ans<<endl; ans1 = max(ans1, ans); vis[a]++; } // for(int i=0; i<100; i++){ // cout << vis[i] << " "; // } // cout<<endl; return ans1; } } }

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

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
   71 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...