QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#614780#8242. V-Diagramyufaiwong5#WA 142ms3880kbC++231.9kb2024-10-05 16:56:222024-10-05 16:56:24

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 16:56:24]
  • 评测
  • 测评结果:WA
  • 用时:142ms
  • 内存:3880kb
  • [2024-10-05 16:56:22]
  • 提交

answer

#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

void run() {
    int aSize;
    cin >> aSize;
    long long int a[aSize];
    
    long long int sumAll = 0;
    for(int i=0; i<aSize; i++) {
        cin >> a[i];
        sumAll += a[i];
    }
    
    int lwl = 0, rwl = aSize >> 1, lwr = rwl - 1, rwr = aSize - 1;
    
    int lSize = lwr - lwl + 1, rSize = rwr - rwl + 1;
    //cout << "LSize " << lSize << " " << " lwr " << lwr << " lwl " << lwl << endl;
    //cout << "RSize " << rSize << " " << " rwr " << rwr << " rwl " << rwl << endl;
    long long int ra[rSize + 1];
    double raa[rSize], rMax = 0.0, rMaxI;
    ra[0] = 0;
    for(int i=1; i <= rSize ; i++) {
        ra[i] = ra[i-1] + a[rwl + i - 1];
        raa[i - 1] = (double) ra[i] / i;
        
        if(raa[i-1] > rMax) {
            rMax = raa[i - 1];
            rMaxI = rwl + i - 1;
        }
        
        //cout << setprecision(21) << raa[i - 1] << " ";
    }
    
    //cout << endl;
    
    long long int la[lSize + 1];
    double laa[lSize], lMax = 0.0, lMaxI = 1;
    la[0] = 0;
    for(int i=1; i <= lSize ; i++) {
        la[i] = la[i-1] + a[lwr - i + 1];
        laa[i - 1] = (double) la[i] / i;
        if(laa[i-1] > lMax) {
            lMax = laa[i - 1];
            lMaxI = lwr - i + 1;
        }
        // cout << setprecision(21) << laa[i - 1] << " ";
    }
    //cout << endl;
    
    // cout << "RMaxI " << rMaxI << " LMaxI " << lMaxI << endl;
    // cout << "rMax = " << setprecision(21) << rMax << " lMax = " << setprecision(21) << lMax << " Sum = " << setprecision(21) << ((rMax + lMax) / (2)) << endl;
    
    // cout << setprecision(21) << avg << endl;
    cout << setprecision(18) << ((rMax + lMax) / 2.0) << endl;
}

int main()
{
    int k;
    cin >> k;
    for(int i=0; i<k; i++) run();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3880kb

input:

2
4
8 2 7 10
6
9 6 5 3 4 8

output:

6.75
5.83333333333333393

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 142ms
memory: 3820kb

input:

100000
3
948511478 739365502 813471668
3
881046825 27458122 398507422
3
987554257 399092415 924260278
3
984128569 125199021 716360525
3
529589236 45783262 313507287
3
645443456 85994112 226010681
3
914820717 228360911 572267310
3
418958362 56703604 195276041
3
64461646 26764720 26995581
3
914535039 ...

output:

862465031.5
547014798.5
824615301.75
702454171
354617255.25
400722926.25
657567413.75
272474092.25
45670898.25
516074063
775704407.5
833048104.25
579052075.5
651237145.25
463029280.25
691366080.75
639588048.5
667117075.25
812657481.75
642528446.75
562934992.75
565828035.75
634204527.75
351444431.75
...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '862465031.5000000', error = '0.0344000'