QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576828#9313. Make MaxlxpyydsWA 0ms3524kbC++141.0kb2024-09-19 22:47:272024-09-19 22:47:27

Judging History

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

  • [2024-09-19 22:47:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2024-09-19 22:47:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int op = 0;
        vector<int> dp(n);
        map<int, int> mp;
        map<int, int> kp;

        for (int i = 0; i < n; i++) {
            cin >> dp[i];
            mp[dp[i]] = i;
            kp[dp[i]] = 1;
        }

        for (auto it = mp.begin(); it != mp.end(); ++it) {
            int x = it->first;
            int y = it->second;

            // Ensure y-1 and y+1 are within bounds
            if (y > 0 && y < n - 1) {
                if (dp[y - 1] < dp[y + 1]) {
                    kp[dp[y - 1]] += kp[dp[y]];
                } else {
                    kp[dp[y + 1]] += kp[dp[y]];
                }
            }

            op += kp[dp[y]];
            // Mark the element as processed
            dp[y] = -1; // Or any value that indicates it is processed
        }

        cout << op << endl;
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3524kb

input:

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

output:

2
1
3
3

result:

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