답안 #749988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749988 2023-05-29T03:07:26 Z guagua0407 Semiexpress (JOI17_semiexpress) C++17
100 / 100
46 ms 33296 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pll pair<ll,ll>

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

struct node{
    ll dif,cur,id,val;
    bool operator<(const node &x)const{
        return dif<x.dif;
    }
};

const int mxn=3005;
ll S[mxn];
ll f[mxn][mxn];
ll dp[mxn][mxn];

int main() {_
    int n,m,k;
    cin>>n>>m>>k;
    ll A,B,C;
    cin>>A>>B>>C;
    ll T;
    cin>>T;
    for(int i=0;i<m;i++){
        cin>>S[i];
        S[i]--;
    }
    ll ans=0;
    priority_queue<ll> pq;
    for(int i=1;i<m;i++){
        if(B*S[i]<=T) ans++;
        ll sum=T-B*S[i-1];
        ll pos2;
        int cnt=0;
        for(ll pos=S[i-1];pos<S[i] and sum>=0 and cnt<=k;pos=pos2+1){
            pos2=min(S[i]-1,pos+sum/A);
            //cout<<pos<<' '<<pos2<<'\n';
            if(cnt==0) ans+=pos2-pos;
            else pq.push(pos2-pos+1);
            cnt++;
            sum-=(pos2-pos+1)*C;
        }
    }
    for(int i=0;i<k-m and !pq.empty();i++){
        ans+=pq.top();
        //cout<<pq.top()<<' ';
        pq.pop();
    }
    cout<<ans;
    return 0;
}
//maybe its multiset not set

Compilation message

semiexpress.cpp: In function 'void setIO(std::string)':
semiexpress.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 3 ms 2512 KB Output is correct
22 Correct 2 ms 1492 KB Output is correct
23 Correct 10 ms 8648 KB Output is correct
24 Correct 8 ms 4532 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 29 ms 16836 KB Output is correct
28 Correct 46 ms 33296 KB Output is correct
29 Correct 8 ms 4556 KB Output is correct
30 Correct 3 ms 2432 KB Output is correct