Submission #806698

# Submission time Handle Problem Language Result Execution time Memory
806698 2023-08-04T08:59:05 Z vjudge1 Let's Win the Election (JOI22_ho_t3) C++14
5 / 100
987 ms 384 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define ld long double
using namespace std ;
const int N = 500 ;
int n, k ;
ld a[N + 1], b[N + 1] ;
vector<pair<int, int>> v_neg, v_pos ;
signed main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    cin >> n >> k ;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> a[i] >> b[i] ;
        if(b[i] == -1)
            v_neg.push_back({a[i], b[i]}) ;
        else
            v_pos.push_back({a[i], b[i]}) ;
    }
    sort(v_pos.begin(), v_pos.end()) ;
    sort(v_neg.begin(), v_neg.end()) ;
    if(!v_pos.size())
    {
        ld ans = 0 ;
        for(int i = 0 ; i < k ; i++)
            ans += v_neg[i].fi ;
        cout << fixed << setprecision(11) << ans ;
        return 0 ;
    }
    ld ans = 1e9 ;
    for(int i = 0 ; i < v_pos.size() ; i++)
    {
        for(int j = i ; j < v_pos.size() ; j++)
        {
            vector<pair<int, int>> abu ;
            ld cnt = 1, sum = 0 ;
            for(int q = i ; q <= j ; q++)
                abu.push_back({v_pos[q].se, v_pos[q].fi}) ;
            sort(abu.begin(), abu.end()) ;
            for(int i = 0 ; i < abu.size() ; i++)
            {
                sum += abu[i].fi / cnt ;
                cnt++ ;
            }
//            cout << sum << ' ' ;
            for(int q = 0 ; q < i ; q++)
                    sum += v_pos[q].fi / cnt ;
            for(int q = j + 1 ; q < v_pos.size() ; q++)
                    sum += v_pos[q].fi / cnt ;
            for(int q = 0 ; q < v_neg.size() ; q++)
                sum += v_neg[q].fi / cnt ;
//            cout << i << ' ' << j << ' '<< sum << '\n' ;
            ans = min(ans, sum) ;
        }
    }
    cout << fixed << setprecision(11) << ans ;
    return 0 ;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0 ; i < v_pos.size() ; i++)
      |                     ~~^~~~~~~~~~~~~~
Main.cpp:37: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]
   37 |         for(int j = i ; j < v_pos.size() ; j++)
      |                         ~~^~~~~~~~~~~~~~
Main.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(int i = 0 ; i < abu.size() ; i++)
      |                             ~~^~~~~~~~~~~~
Main.cpp:52:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for(int q = j + 1 ; q < v_pos.size() ; q++)
      |                                 ~~^~~~~~~~~~~~~~
Main.cpp:54:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             for(int q = 0 ; q < v_neg.size() ; q++)
      |                             ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Incorrect 483 ms 360 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 987 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Incorrect 483 ms 360 KB Output isn't correct
13 Halted 0 ms 0 KB -