답안 #1116387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116387 2024-11-21T14:49:31 Z staszic_ojuz Semiexpress (JOI17_semiexpress) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <vector>
using namespace std;

bool Contains(const vector<long long> &v, long long x){
    for (long long el:v){
        if (el==x) return true;
    }
    return false;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, m, kval, a, b, c, t;
    cin>>n>>m>>kval>>a>>b>>c>>t;
    vector<long long> vect(m);
    for (long long i=0;i<m;i++) cin>>vect[i];
    long long best=0;
    for (long long i=t/a;i<=n;i++){
        if (Contains(vect, i)) continue;
        long long ubi;
        for (long long j=0;j<vect.size();j++){
            if (vect[j]>i){
                ubi=j;
                break;
            }
        }
        for (long long j=i+1;j<=n;j++){
            if (i==j||Contains(vect, j)) continue;
            long long ubj;
            for (long long k=0;k<vect.size();k++){
                if (vect[k]>j){
                    ubj=k;
                    break;
                }
            }
            long long expstop=0, current=0;
            for (long long k=2;k<=n;k++){
                if (Contains(vect, k)) expstop++;
                long long time=(vect[expstop]-1)*b;
                if (expstop==ubj-1&&k>=j){
                    time+=(j-vect[ubj-1])*c+(k-j)*a;
                }
                else if (expstop==ubi-1&&k>=i){
                    time+=(i-vect[ubi-1])*c+(k-i)*a;
                }
                else time+=(k-vect[expstop])*a;
                if (time<=t) current++;
            }
            if (best<current) best=current;
        }
    }
    cout<<best<<'\n';
    return 0;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:24:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (long long j=0;j<vect.size();j++){
      |                            ~^~~~~~~~~~~~
semiexpress.cpp:33:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for (long long k=0;k<vect.size();k++){
      |                                ~^~~~~~~~~~~~
semiexpress.cpp:32:23: warning: 'ubj' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |             long long ubj;
      |                       ^~~
semiexpress.cpp:23:19: warning: 'ubi' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |         long long ubi;
      |                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -