Submission #1083421

# Submission time Handle Problem Language Result Execution time Memory
1083421 2024-09-03T05:40:54 Z chromatic Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 348 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;

int main() {
    int n,m; cin >> n >> m;
    vector<int> a(n);
    for(int &x: a) cin >> x;
    multiset<pair<int,int>> s;
    for(int i=0; i<n-1; i++) {
        s.insert({a[i+1]-a[i],i});
    }
    vector<bool> vis(n);
    while(s.rbegin()->first>m) {
        int id=s.rbegin()->second;
        vis[id]=1;
        if(id) {
            s.erase({a[id]-a[id-1],id-1});
        }
        a[id]=a[id+1]-m;
        s.erase(--s.end());
        s.insert({a[id+1]-a[id],id});
        if(id) s.insert({a[id]-a[id-1],id-1});
    }
    //for(int i=0; i<n; i++) cout << a[i] << " \n"[i==n-1];
    int ans=0;
    for(int i=0; i<n; i++) if(vis[i]) ans++;
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -