QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#867682#8889. Ice Cream MachinesKK1729#0 1ms4096kbC++171.7kb2025-01-23 21:18:592025-01-23 21:18:59

Judging History

This is the latest submission verdict.

  • [2025-01-23 21:18:59]
  • Judged
  • Verdict: 0
  • Time: 1ms
  • Memory: 4096kb
  • [2025-01-23 21:18:59]
  • 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+100);
    vector<int> curr(m+100);
    FOR(i,0,n){
        // cout << i << ans << endl;
        if (active[c[i]]){
            curr[c[i]] = nex[i];
            continue;
        }
        ans++;
        int t = 0; int l = 0;
        bool done = false;
        FOR(j,0,k){
            if (machine[j] == -1){
                machine[j] = c[i];
                curr[c[i]] = nex[i];
                active[c[i]] = 1;
                done = true;
                break;
            }else{
                if (curr[machine[j]] > l){
                    l = max(l, curr[machine[j]]);
                    t = j;
                }
            }

        }
        if (done) continue;
        active[machine[t]] = 0;
        machine[t] = c[i];
        active[c[i]] = 1;
        curr[c[i]] = nex[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();
}

详细

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%