답안 #1114645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114645 2024-11-19T10:03:18 Z AdamGS Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); 

    int n, L; cin >> n >> L;

    vector<int> forward(n+1, 0);
    vector<int> time(n+1, 0); 
    int ostatni_od_startu = 0; 
    for (int i = 1; i <= n; i++){
        cin >> forward[i];
        forward[i] = forward[i] - ostatni_od_startu;
        ostatni_od_startu += forward[i]; 
    } forward[0] = L - ostatni_od_startu;// startujemy z zera wiec tego nawet nie loczymy???
    
    for (int i = 1; i <= n; i++){
        cin >> time[i]; 
    }
    
    // sprawdzic ile sie uzyska idac do przodu
    // ile do tylu
    // prefiks i sufiks z tym jak by wziac ity element i sie cofnac na 0
    
    //vector<int> pomiedzy(n, 1); 
    int res = 0; 

    for (int r_fwrd = 0; r_fwrd <= n; r_fwrd++){
        // ruchy do przodu, reszta do tylu
        vector<bool> zebrane(n+1, 0); zebrane[0] = 1; 
        int v = 0; 
        int t = 0; 
        int aktual = 0; 

        for (int i = 0; i <= r_fwrd; i++){
            v++; 
            if(v > n){
                v = 0;
            }
            t += forward[v]; 
            if(t <= time[v] && zebrane[v] == 0){
                aktual++; 
                zebrane[v] = 1;  
            }
            // cout << v << ' ' << (t <= time[r_fwrd]) << '\n';
        }
        int r_back = n - r_fwrd; 
        for (int i = 0; i < 2*r_back; i++){
            
            t += forward[v]; 
            v--; 
            if(v < 0){
                v = n;
            }

            if(t <= time[v] && zebrane[v] == 0){
                aktual++; 
            }
        }
        // cout << r_fwrd << ' ' << aktual << '\n';
        res = max(aktual, res); 
    }


    for (int r_fwrd = 0; r_fwrd <= n; r_fwrd++){
        vector<bool> zebrane(n+1, 0); zebrane[0] = 1; 
        int v = 0; 
        int t = 0; 
        int aktual = 0; 

        int r_back = n - r_fwrd; 
        for (int i = 0; i < r_back; i++){
            t += forward[v]; 
            v--; 
            if(v < 0){
                v = n;
            }

            if(t <= time[v] && zebrane[v] == 0){
                aktual++;
                // cout << v << '\n'; 
                zebrane[v] = 1;  
            }
        }

        for (int i = 0; i < 2*r_fwrd; i++){
            v++; 
            if(v > n) v = 0;

            t += forward[v]; 
            if(t <= time[v] && zebrane[v] == 0){
                aktual++; 
                zebrane[v] = 1;  
                // cout << v << '\n'; 

            }
            //cout << v << ' ' << (t <= time[r_fwrd]) << '\n';
        }

        //  cout << r_fwrd << ' ' << aktual << '\n';

        res = max(aktual, res); 
    }

    

    
    cout << res << '\n'; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -