Submission #877592

#TimeUsernameProblemLanguageResultExecution timeMemory
877592mychecksedadLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
15 ms472 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; int n, k; array<double, 2> a[N]; void solve(){ cin >> n >> k; for(int i = 1; i <= n; ++i){ cin >> a[i][1] >> a[i][0]; if(a[i][0] == -1) a[i][0] = MOD; } sort(a+1, a+1+n); double best = 1000000000; for(int i = 0; i <= n; ++i){ double ans = 0; double x = 1; if(i > 0 && a[i][0] == MOD) break; for(int j = 1; j <= i; ++j){ ans += a[j][0] / x; ++x; } if(k <= i){ best = min(ans, best); break;} sort(a+i+1, a+1+n, [&](const array<double, 2> &z, const array<double, 2> &w){ return z[1] < w[1]; }); for(int j = i + 1; j <= k; ++j){ ans += a[j][1] / x; // cout << a[j][1] << ' '; } best = min(best,ans); sort(a+1, a+1+n); // cout << best << ' '; } cout << fixed << setprecision(15); cout << best; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:50:15: warning: unused variable 'aa' [-Wunused-variable]
   50 |   int tt = 1, aa;
      |               ^~
#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...