Submission #1058443

# Submission time Handle Problem Language Result Execution time Memory
1058443 2024-08-14T10:01:02 Z SzymonKrzywda Bikeparking (EGOI24_bikeparking) C++17
0 / 100
56 ms 5072 KB
#include <bits/stdc++.h>

using namespace std;


int main()
{
    int n;
    cin >> n;
    
    vector<int> tier_(n);
    vector<int> lvl_(n);
    
    for (int i=0; i<n; i++) cin >> tier_[i];
    for (int i=0; i<n; i++) cin >> lvl_[i];
    
    
    vector<int> tier(n);
    vector<int> lvl(n);
    for (int i=0; i<n; i++) tier_[i] = tier[i];
    for (int i=0; i<n; i++) lvl_[i] = lvl[i];
    
    
    int akt_wsk=n-1;
    int wynik = 0,wynik_;
    for (int i=n-1; i>=0; i--){
        
        while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--;
        while (akt_wsk>=0 && lvl[i]>0){
            while (akt_wsk>=0 && akt_wsk>=i) akt_wsk--;
            if (akt_wsk>=i) break;
            int mini = min(tier[akt_wsk],lvl[i]);
            tier[akt_wsk]-=mini;
            lvl[i]-=mini;
            wynik+=mini;
            while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--;
        }
        
    }
    
    akt_wsk=n-1;
    
    for (int i=0; i<n; i++){
        if (lvl[i]>0){
            int mini = min(tier[i],lvl[i]);
            tier[i] -= mini;
            lvl[i] -= mini;
            while (lvl[i]>0){
                while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--;
                int mini = min(tier[akt_wsk],lvl[i]);
                tier[i] -= mini;
                lvl[i] -= mini;
                wynik-=mini;
            }
        }
    }
    
    wynik_=wynik;
    //sposob drugi
    
       
    for (int i=0; i<n; i++) tier_[i] = tier[i];
    for (int i=0; i<n; i++) lvl_[i] = lvl[i];
    akt_wsk=0;
    wynik = 0;
    
    
    for (int i=0; i<n; i++){
        
        while (akt_wsk<i && lvl[i]>0){
            int mini = min(tier[akt_wsk],lvl[i]);
            tier[akt_wsk]-=mini;
            lvl[i]-=mini;
            wynik+=mini;
            if (tier[akt_wsk]==0) akt_wsk++;
            while (akt_wsk < n && tier[akt_wsk]==0) akt_wsk++;
        }
        
    }
    
    akt_wsk=n-1;
    
    for (int i=0; i<n; i++){
        if (lvl[i]>0){
            int mini = min(tier[i],lvl[i]);
            tier[i] -= mini;
            lvl[i] -= mini;
            while (lvl[i]>0){
                while (akt_wsk >= 0 && tier[akt_wsk]==0) akt_wsk--;
                int mini = min(tier[akt_wsk],lvl[i]);
                tier[i] -= mini;
                lvl[i] -= mini;
                wynik-=mini;
            }
        }
    }
    
    
    wynik_=max(wynik,wynik_);
    
    cout << wynik << endl;
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 56 ms 5072 KB Output is correct
3 Incorrect 42 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -