Submission #466884

# Submission time Handle Problem Language Result Execution time Memory
466884 2021-08-20T23:06:20 Z TlenekWodoru Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 5324 KB
#include <bits/stdc++.h>
using namespace std;
int srednica[100009];
int pojemnosc[100009];
vector<int>D[100009];
int graf[100009];
int main()
{ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        int r,l;
        cin>>r>>l;
        srednica[i]=r;
        pojemnosc[i]=l;
    }
///-=-=-==-==-=-==-==-=-=-==-=-==-==-==-=-==-==-=-==-=-==-==-=-=-=
///-==-=--==-==-=-==-==--==--==-==-=-==-==-=-==-==-==-=-==-==-=-==-
    /**cout<<endl<<endl;
    for(int i=0;i<=n;i++)
    {
        cout<<endl<<"i="<<i<<"| ";
        for(int j=0;j<10;j++)
        {
            cout<<V[i][j]<<" ";
        }
    }
    cout<<endl;
    cout<<endl;
    for(int i=0;i<=n;i++)
    {
        cout<<endl<<"i="<<i<<"| ";
        for(int j=0;j<10;j++)
        {
            cout<<V2[i][j]<<" ";
        }
    }
    cout<<endl<<endl;**/
///-=-==-=-==-=-==-=-==-==-=-===-=-==-==-=-==-=-==-==--=-=
    vector<int>odp;
    for(int i=1;i<=m;i++)
    {
        int ind;
        int k;
        cin>>ind>>k;
        while(ind!=0)
        {
            if(k>pojemnosc[ind])
            {
                k-=pojemnosc[ind];
                bool cv=0;
                for(int j=ind+1;j<=n;j++)
                {
                    if(srednica[j]>srednica[ind])
                    {
                        cv=1;
                        ind=j;
                        break;
                    }
                }
                if(cv==0){ind=0;}
            }
            else
            {
                break;
            }
        }
        odp.push_back(ind);
    }
    for(int i=0;i<odp.size();i++)
    {
        cout<<odp[i]<<endl;
    }
    return 0;
}
/**
10 100
1 1
2 1
3 1
4 2
5 2
6 2
7 3
8 3
9 3
10 4

**/





Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:71:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for(int i=0;i<odp.size();i++)
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 4 ms 2636 KB Output is correct
4 Correct 5 ms 2636 KB Output is correct
5 Correct 6 ms 2684 KB Output is correct
6 Correct 8 ms 2680 KB Output is correct
7 Correct 5 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1596 ms 5324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 4 ms 2636 KB Output is correct
4 Correct 5 ms 2636 KB Output is correct
5 Correct 6 ms 2684 KB Output is correct
6 Correct 8 ms 2680 KB Output is correct
7 Correct 5 ms 2636 KB Output is correct
8 Execution timed out 1596 ms 5324 KB Time limit exceeded
9 Halted 0 ms 0 KB -