Submission #1072321

#TimeUsernameProblemLanguageResultExecution timeMemory
1072321_rain_Let's Win the Election (JOI22_ho_t3)C++14
11 / 100
2561 ms604 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fixbug true void SETIO(string name = ""){ if (name=="") return; freopen((name+".inp").c_str(),"r",stdin); freopen((name+".ans").c_str(),"w+",stdout); return; } const int maxn = 500; const int maxk = 500; const int INF = 1e9 + 7; int n , k ; pair<double,double> a[maxn+2]; #define fi first #define se second bool f[maxn+2]; vector<pair<int,int>> v; double ans = INF; vector<pair<int,int>> store; void calc(int id){ if (id==k+1){ double cnt = 1 ; double sum = 0; for (int i = 0; i < v.size(); ++i){ if (v[i].se == 1) { sum = sum + a[v[i].fi].fi / cnt; } else { sum = sum + a[v[i].fi].se / cnt; ++cnt; } } ans = min(ans , sum); return; } for (int i = 0; i < n; ++i){ if (!f[i]){ f[i] = 1; if (a[i].se != -1){ v.push_back({i,0}); calc(id+1); v.pop_back(); } v.push_back({i,1}); calc(id+1); v.pop_back(); f[i] = 0; } } return; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); SETIO(""); cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[i].fi >> a[i].se; if (a[i].se==-1) a[i].se = INF; } calc(1); cout << setprecision(9) << fixed << ans; }

Compilation message (stderr)

Main.cpp: In function 'void calc(int)':
Main.cpp:30:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int i = 0; i < v.size(); ++i){
      |                         ~~^~~~~~~~~~
Main.cpp: In function 'void SETIO(std::string)':
Main.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen((name+".inp").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen((name+".ans").c_str(),"w+",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...