Submission #1058540

# Submission time Handle Problem Language Result Execution time Memory
1058540 2024-08-14T10:43:55 Z user736482 Bikeparking (EGOI24_bikeparking) C++17
0 / 100
1000 ms 12640 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,t,n,x,y,m,q,store,st2;
vector<long long>v1,v2;
stack<long long>s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    long long res=0;
    for(long long i=0;i<n;i++){
        cin>>a;
        v1.push_back(a);
    }
    for(long long i=0;i<n;i++){
        cin>>a;
        v2.push_back(a);
    }
    long long pt1=n-1,pt2=n-1;
    pt2=n-1;
    while(pt2>=0){
        res-=v2[pt2];
        pt2--;

    }
    if(a)
    s.push(a);
    store=min(v1[n-1],v2[n-1]);
    v2[n-1]=0;
   // cout<<res;
    st2=res;
    //return 0;
    pt2=n-1;
    while(pt1>=0){
            //cout<<pt1<<" "<<pt2<<"   ";
        if(pt1>=pt2 || v1[pt1]==0){
            pt1--;
            continue;

        }
        while(pt2-1>pt1){
            pt2--;
            if(v2[pt2])
                s.push(v2[pt2]);
            v2[pt2]=0;
        }
        if(s.empty()){
                pt2--;
        if(v2[pt2])
                s.push(v2[pt2]);
                if(s.size()==1)
                store=min(v1[pt2],v2[pt2]);
            continue;}
        v2[pt2]=s.top();
        s.pop();
        if(v2[pt2]>=v1[pt1]){
            v2[pt2]-=v1[pt1];
            res+=2*v1[pt1];
            v1[pt1]=0;
        }
        else{
            v1[pt1]-=v2[pt2];
            res+=2*v2[pt2];
            v2[pt2]=0;
        }
            if(v2[pt2])
                s.push(v2[pt2]);
            v2[pt2]=0;

    }
    //cout<<res;
    while(s.size()>1)
        s.pop();
    if(!s.empty())
        res+=min(store,s.top());
    else if(res!=-st2)
        while(1)
            int p=2137;
    //return 0;
    //v2[pt2]-=min(v2[pt2],v1[pt2]);
    //cout<<res;

    cout<<res;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   50 |         if(v2[pt2])
      |         ^~
Main.cpp:52:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   52 |                 if(s.size()==1)
      |                 ^~
Main.cpp:79:17: warning: unused variable 'p' [-Wunused-variable]
   79 |             int p=2137;
      |                 ^
# 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 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Execution timed out 1094 ms 348 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 1095 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 20 ms 12640 KB Output is correct
3 Execution timed out 1068 ms 8912 KB Time limit exceeded
4 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 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Execution timed out 1094 ms 348 KB Time limit exceeded
20 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 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Execution timed out 1094 ms 348 KB Time limit exceeded
20 Halted 0 ms 0 KB -