Submission #824395

# Submission time Handle Problem Language Result Execution time Memory
824395 2023-08-14T05:17:12 Z Amylopectin Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
1 ms 340 KB
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int mxn = 2010;
struct we
{
    double aa,bb,bsa;
    int idx;
};
bool cmp1(const struct we &l,const struct we &r)
{
    return l.aa < r.aa;
}
bool cmp2(const struct we &l,const struct we &r)
{
    if(l.bb == -1)
    {
        return false;
    }
    if(r.bb == -1)
    {
        return true;
    }
    if(l.bsa == r.bsa)
    {
        return l.aa < r.aa;
    }
    return l.bsa < r.bsa;
}
struct we soa[mxn] = {},sob[mxn] = {};
int u[mxn] = {};
int main()
{
    int i,j,n,m,cn,cm,fn,fm,cou;
    double cva,cmi,f,p;
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%lf %lf",&soa[i].aa,&soa[i].bb);
        soa[i].bsa = soa[i].bb - soa[i].aa;
        soa[i].idx = i;
        sob[i] = {soa[i].aa,soa[i].bb,soa[i].bsa,i};
    }
    sort(soa,soa+n,cmp1);
    sort(sob,sob+n,cmp2);
    for(i=0; i<n; i++)
    {
        if(i > 0 && sob[i-1].bb == -1)
        {
            break;
        }
        cva = 0;
        for(j=0; j<i; j++)
        {
            u[sob[j].idx] = 1;
            f = j + 1;
            cva += sob[j].bb / f;
        }
        f = i+1;
        cou = i;
        for(j=0; j<n; j++)
        {
            if(u[soa[j].idx] == 0)
            {
                cou ++;
                cva += soa[j].aa / f;
            }
            if(cou == m)
            {
                break;
            }
        }
        if(i == 0)
        {
            cmi = cva;
        }
        else 
        {
            cmi = min(cmi,cva);
        }
    }
    printf("%lf\n",cmi);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:17: warning: unused variable 'cn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                 ^~
Main.cpp:35:20: warning: unused variable 'cm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                    ^~
Main.cpp:35:23: warning: unused variable 'fn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                       ^~
Main.cpp:35:26: warning: unused variable 'fm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou;
      |                          ^~
Main.cpp:36:22: warning: unused variable 'p' [-Wunused-variable]
   36 |     double cva,cmi,f,p;
      |                      ^
Main.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%lf %lf",&soa[i].aa,&soa[i].bb);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Incorrect 0 ms 212 KB Output isn't correct
28 Halted 0 ms 0 KB -