답안 #873291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873291 2023-11-14T19:02:57 Z Andreibatman Stove (JOI18_stove) C++14
100 / 100
58 ms 5956 KB
#include <bits/stdc++.h>
using namespace std;
long long n,k,i,v[100010],timp;
map<long long,long long>fr,fr2;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
        if(i>1)
            fr[-(v[i]-v[i-1])]++;
    }
    k--;
    for(auto it:fr)
    {
        if(k==0)
            break;
        if(it.first==-1)
            continue;
        fr2[it.first]+=min(k,it.second);
        k-=min(k,it.second);
    }
    timp=1;
    for(i=2;i<=n;i++)
    {
        if(v[i]-v[i-1]==1)
            timp++;
        else
        {
            if(!fr2[v[i-1]-v[i]])
                timp+=v[i]-v[i-1];
            else
            {
                fr2[v[i-1]-v[i]]--;
                timp++;
            }
        }
    }
    cout<<timp;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 2 ms 872 KB Output is correct
13 Correct 2 ms 856 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 2 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 2 ms 872 KB Output is correct
13 Correct 2 ms 856 KB Output is correct
14 Correct 2 ms 860 KB Output is correct
15 Correct 2 ms 856 KB Output is correct
16 Correct 46 ms 5956 KB Output is correct
17 Correct 40 ms 5784 KB Output is correct
18 Correct 39 ms 5716 KB Output is correct
19 Correct 41 ms 5712 KB Output is correct
20 Correct 48 ms 5724 KB Output is correct
21 Correct 58 ms 5808 KB Output is correct
22 Correct 54 ms 5780 KB Output is correct
23 Correct 53 ms 5796 KB Output is correct
24 Correct 54 ms 5760 KB Output is correct