답안 #1072321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072321 2024-08-23T17:01:53 Z _rain_ Let's Win the Election (JOI22_ho_t3) C++14
11 / 100
2500 ms 604 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fixbug true


void SETIO(string name = ""){
    if (name=="") return;
    freopen((name+".inp").c_str(),"r",stdin);
    freopen((name+".ans").c_str(),"w+",stdout);
    return;
}

const int maxn = 500;
const int maxk = 500;
const int INF = 1e9 + 7;
int n , k ;
pair<double,double> a[maxn+2];
#define fi first
#define se second
bool f[maxn+2];
vector<pair<int,int>> v;
double ans = INF;
vector<pair<int,int>> store;

void calc(int id){
    if (id==k+1){
        double cnt = 1 ;
        double sum = 0;
        for (int i = 0; i < v.size(); ++i){
            if (v[i].se == 1) {
                sum = sum + a[v[i].fi].fi / cnt;
            }
            else {
                sum = sum + a[v[i].fi].se / cnt;
                ++cnt;
            }
        }
        ans = min(ans , sum);
        return;
    }
    for (int i = 0; i < n; ++i){
        if (!f[i]){
            f[i] = 1;
            if (a[i].se != -1){
                v.push_back({i,0});
                calc(id+1);
                v.pop_back();
            }
            v.push_back({i,1});
            calc(id+1);
            v.pop_back();
            f[i] = 0;
        }
    }
    return;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    SETIO("");

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].fi >> a[i].se;
        if (a[i].se==-1) a[i].se = INF;
    }
    calc(1);
    cout << setprecision(9) << fixed << ans;
}


Compilation message

Main.cpp: In function 'void calc(int)':
Main.cpp:30: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]
   30 |         for (int i = 0; i < v.size(); ++i){
      |                         ~~^~~~~~~~~~
Main.cpp: In function 'void SETIO(std::string)':
Main.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen((name+".inp").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen((name+".ans").c_str(),"w+",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Execution timed out 2519 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Execution timed out 2519 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 7 ms 464 KB Output is correct
7 Correct 16 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 16 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 7 ms 464 KB Output is correct
7 Correct 16 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 16 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Execution timed out 2561 ms 348 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 7 ms 464 KB Output is correct
7 Correct 16 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 16 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Execution timed out 2561 ms 348 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2547 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Execution timed out 2519 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -