Submission #526352

#TimeUsernameProblemLanguageResultExecution timeMemory
526352model_codeLet's Win the Election (JOI22_ho_t3)C++17
10 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; int N, K, A[509], B[509]; vector<int> vec1, vec2; int main() { // 入力 cin >> N >> K; for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; if (B[i] == -1) vec1.push_back(A[i]); if (B[i] == A[i]) vec2.push_back(A[i]); } // ソート sort(vec1.begin(), vec1.end()); sort(vec2.begin(), vec2.end()); // 答えを求める double Answer = 1e9; for (int Goal = 0; Goal <= K; Goal++) { if (K - Goal > vec1.size() || Goal > vec2.size()) continue; double sum = 0; for (int i = 0; i < K - Goal; i++) sum += 1.0 * vec1[i] / (Goal+1); for (int i = 0; i < Goal; i++) sum += 1.0 * vec2[i] / (i+1); Answer = min(Answer, sum); } printf("%.12lf\n", Answer); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (K - Goal > vec1.size() || Goal > vec2.size()) continue;
      |       ~~~~~~~~~^~~~~~~~~~~~~
Main.cpp:23:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (K - Goal > vec1.size() || Goal > vec2.size()) continue;
      |                                 ~~~~~^~~~~~~~~~~~~
#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...