답안 #824404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824404 2023-08-14T05:32:49 Z Amylopectin Let's Win the Election (JOI22_ho_t3) C++14
28 / 100
2467 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.bb == r.bb)
    {
        return l.aa > r.aa;
    }
    return l.bb < r.bb;
}
struct we soa[mxn] = {},sob[mxn] = {};
int u[mxn] = {};
int main()
{
    int i,j,n,m,cn,cm,fn,fm,cou,cru,po;
    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);
    cru = n;
    for(i=0; i<n; i++)
    {
        if(sob[i].bb == -1)
        {
            cru = i;
            break;
        }
    }
    po = 1<<cru;
    for(i=0; i<po; i++)
    {
        cva = 0;
        cou = 0;
        for(j=0; j<n; j++)
        {
            u[j] = 0;
        }
        for(j=0; j<cru; j++)
        {
            if((1<<j) & i)
            {
                u[sob[j].idx] = 1;
                f = cou + 1;
                cva += sob[j].bb / f;
                cou ++;
            }
        }
        f = cou+1;
        // cou ++;
        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,cru,po;
      |                 ^~
Main.cpp:35:20: warning: unused variable 'cm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou,cru,po;
      |                    ^~
Main.cpp:35:23: warning: unused variable 'fn' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou,cru,po;
      |                       ^~
Main.cpp:35:26: warning: unused variable 'fm' [-Wunused-variable]
   35 |     int i,j,n,m,cn,cm,fn,fm,cou,cru,po;
      |                          ^~
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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 304 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 308 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 304 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 308 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 212 KB Output is correct
12 Incorrect 1258 ms 320 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 155 ms 340 KB Output is correct
17 Correct 122 ms 212 KB Output is correct
18 Correct 12 ms 212 KB Output is correct
19 Correct 91 ms 296 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 2 ms 308 KB Output is correct
22 Correct 93 ms 300 KB Output is correct
23 Correct 6 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 142 ms 212 KB Output is correct
26 Correct 37 ms 212 KB Output is correct
27 Correct 80 ms 212 KB Output is correct
28 Correct 86 ms 296 KB Output is correct
29 Correct 81 ms 212 KB Output is correct
30 Correct 81 ms 296 KB Output is correct
31 Correct 80 ms 296 KB Output is correct
32 Correct 94 ms 296 KB Output is correct
33 Correct 86 ms 296 KB Output is correct
34 Correct 99 ms 300 KB Output is correct
35 Correct 103 ms 340 KB Output is correct
36 Correct 101 ms 212 KB Output is correct
37 Correct 110 ms 296 KB Output is correct
38 Correct 102 ms 296 KB Output is correct
39 Correct 114 ms 304 KB Output is correct
40 Correct 102 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 155 ms 340 KB Output is correct
17 Correct 122 ms 212 KB Output is correct
18 Correct 12 ms 212 KB Output is correct
19 Correct 91 ms 296 KB Output is correct
20 Correct 6 ms 212 KB Output is correct
21 Correct 2 ms 308 KB Output is correct
22 Correct 93 ms 300 KB Output is correct
23 Correct 6 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 142 ms 212 KB Output is correct
26 Correct 37 ms 212 KB Output is correct
27 Correct 80 ms 212 KB Output is correct
28 Correct 86 ms 296 KB Output is correct
29 Correct 81 ms 212 KB Output is correct
30 Correct 81 ms 296 KB Output is correct
31 Correct 80 ms 296 KB Output is correct
32 Correct 94 ms 296 KB Output is correct
33 Correct 86 ms 296 KB Output is correct
34 Correct 99 ms 300 KB Output is correct
35 Correct 103 ms 340 KB Output is correct
36 Correct 101 ms 212 KB Output is correct
37 Correct 110 ms 296 KB Output is correct
38 Correct 102 ms 296 KB Output is correct
39 Correct 114 ms 304 KB Output is correct
40 Correct 102 ms 212 KB Output is correct
41 Incorrect 1 ms 308 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2467 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 304 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 308 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 212 KB Output is correct
12 Incorrect 1258 ms 320 KB Output isn't correct
13 Halted 0 ms 0 KB -