답안 #658939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658939 2022-11-15T13:59:23 Z Jeff12345121 말 (IOI15_horses) C++14
34 / 100
22 ms 12304 KB
#include <bits/stdc++.h>
#include "horses.h"

#define REP(i,n) for(int i = 1; i <= (n); i++)
using namespace std;

#ifdef LOCAL
ifstream in("in.in");
ofstream out("out.out");
#endif

const int nmax = 1005;
long long n,x[nmax],y[nmax],inf = (1LL << 60),MOD = 1000000007;
double logx[nmax],logy[nmax];

int compute() {
    double horses_log = 0,max_sol_log = -inf;
    long long horses_mod = 1, max_sol_mod = -inf;
    
    for (int i = 0; i < n; i++) {
        horses_log = horses_log + logx[i];
        horses_mod = horses_mod * x[i] % MOD;

        if (horses_log + logy[i] > max_sol_log) {
            max_sol_log = horses_log + logy[i];
            max_sol_mod = horses_mod * y[i] % MOD;            
        }
    }

    return  max_sol_mod % MOD;
}
int init(int tn, int* tx,int* ty) {
    n = tn;
    for (int i = 0; i < n; i++) {
        x[i] = tx[i];
        logx[i] = log(x[i]);
        y[i] = ty[i];
        logy[i] = log(ty[i]);
    }

    return compute();
}
int updateX(int pos, int val) {
    x[pos] = val;
    logx[pos] = log(x[pos]);
    return compute();
}

int updateY(int pos, int val) {
    y[pos] = val;
    logy[pos] = log(y[pos]);
    return compute();
}

#ifdef LOCAL
int tx[nmax],ty[nmax];
int32_t main() {
    in >> n;
    for (int i = 0; i < n; i++) {
        in >> tx[i];
    }
    for (int i = 0; i < n; i++) {
        in >> ty[i];
    }

    out << init(n,tx,ty) << "\n";
    int m;
    in >> m;
    for (int i = 0; i < m; i++) {
        int type,pos,val;
        in >> type >> pos >> val;
        if (type == 0) {
            out << updateX(pos, val);
        }
        if (type == 1) {
            out << updateY(pos,val);
        }
    }
}
#endif

Compilation message

horses.cpp: In function 'int compute()':
horses.cpp:17:41: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   17 |     double horses_log = 0,max_sol_log = -inf;
      |                                         ^~~~
horses.cpp:30:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   30 |     return  max_sol_mod % MOD;
      |             ~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 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 0 ms 212 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 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 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 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 0 ms 212 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 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 8 ms 312 KB Output is correct
24 Correct 8 ms 360 KB Output is correct
25 Correct 19 ms 316 KB Output is correct
26 Correct 19 ms 340 KB Output is correct
27 Correct 6 ms 340 KB Output is correct
28 Correct 9 ms 356 KB Output is correct
29 Correct 5 ms 340 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 5 ms 316 KB Output is correct
32 Correct 5 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 8384 KB Execution killed with signal 11
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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 280 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 8 ms 364 KB Output is correct
24 Correct 8 ms 316 KB Output is correct
25 Correct 19 ms 380 KB Output is correct
26 Correct 19 ms 348 KB Output is correct
27 Correct 6 ms 316 KB Output is correct
28 Correct 10 ms 360 KB Output is correct
29 Correct 5 ms 316 KB Output is correct
30 Correct 10 ms 356 KB Output is correct
31 Correct 5 ms 316 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
33 Runtime error 22 ms 12304 KB Execution killed with signal 11
34 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 220 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 8 ms 340 KB Output is correct
24 Correct 8 ms 340 KB Output is correct
25 Correct 20 ms 356 KB Output is correct
26 Correct 19 ms 372 KB Output is correct
27 Correct 6 ms 364 KB Output is correct
28 Correct 10 ms 340 KB Output is correct
29 Correct 5 ms 340 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 5 ms 356 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Runtime error 14 ms 10488 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -