Submission #533059

#TimeUsernameProblemLanguageResultExecution timeMemory
533059victor_gaoLet's Win the Election (JOI22_ho_t3)C++17
11 / 100
2581 ms424 KiB
//#pragma GCC optimize("Ofast,unroll-loops,O3") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native") #include<bits/stdc++.h> //#include<bits/extc++.h> //#pragma pack(1) #define fast ios::sync_with_stdio(0); cin.tie(0); #define int long long #define pii pair<int,int> #define x first #define y second #define N 515 using namespace std; //using namespace __gnu_pbds; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset; //typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set; int n,k,a[N],b[N]; long double dp[N][N],ans=1e100; bool vis[N]; vector<int>np; void solve(){ do { for (int i=1;i<=n;i++){ for (int j=0;j<=n;j++) dp[i][j]=1e100; } for (int i=1;i<=np.size();i++){ for (int j=0;j<=i;j++){ if (j!=i) dp[i][j]=min(dp[i][j],dp[i-1][j]+(long double)a[np[i-1]]/(long double)(j+1)); if (j&&b[np[i-1]]!=-1) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(long double)b[np[i-1]]/(long double)(j)); } } long double tans=1e100; for (int i=0;i<np.size();i++){ tans=min(tans,dp[np.size()][i]); } ans=min(tans,ans); // for (auto i:np) cout<<i; // cout<<" -> "<<tans<<'\n'; }while (next_permutation(np.begin(),np.end())); } signed main(){ fast cout<<fixed<<setprecision(20); cin>>n>>k; for (int i=0;i<n;i++){ cin>>a[i]>>b[i]; } for (int i=1;i<(1LL<<n);i++){ np.clear(); for (int j=0;j<n;j++){ if (i&(1LL<<j)){ np.push_back(j); } } if (np.size()==k) solve(); } cout<<ans<<'\n'; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:26:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int i=1;i<=np.size();i++){
      |                ~^~~~~~~~~~~
Main.cpp:33:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i=0;i<np.size();i++){
      |                ~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:55:16: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   55 |   if (np.size()==k) solve();
      |       ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...