Submission #533061

#TimeUsernameProblemLanguageResultExecution timeMemory
533061victor_gaoLet's Win the Election (JOI22_ho_t3)C++17
23 / 100
2597 ms332 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],ans=1e100; bool vis[N]; vector<pii>tog,all; void solve(){ sort(tog.begin(),tog.end()); for (int i=0;i<=n;i++) vis[i]=0; long double tans=0; for (int i=0;i<tog.size();i++){ tans+=(long double)tog[i].x/(long double)(i+1); vis[tog[i].y]=1; } int need=k-tog.size(),total=0; for (int i=1;i<=n&&need;i++){ if (!vis[all[i-1].y]){ need--; total+=all[i-1].x; } } tans+=(long double)total/(long double)(tog.size()+1); // cout<<" -> "<<tans<<'\n'; ans=min(ans,tans); } signed main(){ fast cout<<fixed<<setprecision(20); cin>>n>>k; for (int i=0;i<n;i++){ cin>>a[i]>>b[i]; all.push_back({a[i],i}); } sort(all.begin(),all.end()); for (int i=0;i<(1LL<<n);i++){ tog.clear(); for (int j=0;j<n;j++){ if (i&(1LL<<j)){ if (b[j]!=-1) tog.push_back({b[j],j}); } } if (tog.size()<=k) solve(); } cout<<ans<<'\n'; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:25:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i=0;i<tog.size();i++){
      |               ~^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:56:17: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   56 |   if (tog.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...