QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#576641#9313. Make MaxloogicWA 174ms14608kbC++141.3kb2024-09-19 21:23:472024-09-19 21:23:47

Judging History

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

  • [2024-09-19 21:23:47]
  • 评测
  • 测评结果:WA
  • 用时:174ms
  • 内存:14608kb
  • [2024-09-19 21:23:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// 璇彞 
#define FAST std::ios::sync_with_stdio(false), cin.tie(0),cout.tie(0);
// 鍒悕 
//#define int long long   // 寤剁紦寰幆閫熷害锛屼絾鍙互鐢�
#define PI      acos(-1)
#define EPS     1e-9
using ll = long long;
using lb = long double;     // 娴偣鍨�
using PII = pair<int, int>; // pair
const int P = 1;            // 鍙栦綑
const int M = 0;
const int N = 0+5;


inline void solve() {
	int n; cin >> n;
    vector<int> iv(n);

    int mex = -1;
    for (int i = 0; i < n; ++i) {
        cin >> iv[i];
        mex = max(mex, iv[i]);
    }
    vector<int> arr(iv);
    


	sort(iv.begin(), iv.end());
	iv.erase(unique(iv.begin(), iv.end()), iv.end());
    
    unordered_map<int, int> mm;
    for (int i = 0; i < iv.size(); ++i) {
        mm[iv[i]] = i + 1;
        //cout << mm[iv[i]] << ' '; 
    }
    mex = mm[mex];
    // for (auto t: iv)
    //     cout << t << ' ';
    //cout << '\n'; 

    int ans = 0;
    for (int t: arr) {
        ans += mex - mm[t];
    }
    cout << ans << '\n';
    
}

signed main() {
    //FAST
    int TTT = 1;
    cin >> TTT; // 澶氱粍杈撳叆
    while (TTT--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
3
3

result:

ok 4 number(s): "1 0 3 3"

Test #2:

score: -100
Wrong Answer
time: 174ms
memory: 14608kb

input:

2
198018
875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...

output:

-1871121288
1010448805

result:

wrong answer 1st numbers differ - expected: '4084978', found: '-1871121288'