QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#867700#8889. Ice Cream MachinesKK1729#0 1ms4096kbC++171.7kb2025-01-23 21:39:352025-01-23 21:39:36

Judging History

This is the latest submission verdict.

  • [2025-01-23 21:39:36]
  • Judged
  • Verdict: 0
  • Time: 1ms
  • Memory: 4096kb
  • [2025-01-23 21:39:35]
  • Submitted

answer

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

#define int long long 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"

void printVector(vector<int> a){
    for (auto x: a) cout << x << " ";
    cout << endl;
}

void solve(){
    int n, m, k; cin >> n >> m >> k;
    vector<int> c(n);
    FOR(i,0,n) cin >> c[i];

    int ans = 0;
    vector<vector<int>> e(m+100);
    FOR(i,0,n) e[c[i]].pb(i);
    vector<int> nex(n+1, 1e9);
    FOR(i,1,m+1){
        if (e[i].size() == 0) continue;
        FOR(j,0,e[i].size()-1) nex[e[i][j]] = e[i][j+1];
    }
    vector<int> machine(k, -1);
    vector<int> active(m+1);
    vector<int> curr(m+1);
    multiset<pair<int, int>> machines;
    FOR(i,0,k) machines.insert({-1e9, -1});
    FOR(i,0,n){
        if (active[c[i]]){
            auto x = *machines.find({-curr[c[i]], c[i]});
            machines.erase(machines.find(x));
            curr[c[i]] = nex[i];
            machines.insert({-curr[c[i]], c[i]});
            continue;
        }else{
        ans++;
        
        auto x = *machines.begin();
        int ind = x.second;
        
        if (ind == -1){
            active[c[i]] = 1;
            curr[c[i]] = nex[i];
        }else{
            active[ind] = 0;
            active[c[i]] = 1;
            curr[c[i]] = nex[i];
        }
        machines.erase(machines.find(x));
        machines.insert({-(nex[i]), c[i]});
    }

    }
    cout << ans << endl;
}


int32_t main(){
    freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int t = 1; // cin >> t;
    while (t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4096kb

input:

1000 10 1
3
6
6
8
4
7
4
10
1
6
6
2
1
8
4
10
5
9
3
4
7
5
9
6
2
8
8
7
1
1
1
9
8
6
4
6
5
4
8
8
2
3
1
7
7
10
4
10
5
5
2
7
5
1
6
8
7
9
10
4
9
2
4
5
7
8
10
9
1
5
1
7
10
4
10
10
5
10
10
10
5
3
5
5
7
4
6
6
10
6
9
5
6
3
3
3
7
10
7
4
5
10
6
4
2
4
8
7
6
9
7
5
6
9
9
7
4
5
8
8
10
6
1
4
9
3
9
10
1
7
3
4
8
1
3
9
5...

output:

0

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%