Submission #91120

# Submission time Handle Problem Language Result Execution time Memory
91120 2018-12-26T10:07:29 Z Aydarov03 Divide and conquer (IZhO14_divide) C++14
0 / 100
719 ms 1100 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int pl[100005] , g[100005] , e[100005];
int n , l = 0 , r = 1;

inline bool check( ll mid )
{
    int energy = e[1];
	int lenergy = 0;
	int ggold = g[1];


    for(int i = 1; i <= n; i++)
    {
        ggold = 0;
        lenergy = 0;
        energy = 0;

        for(int j = i; j <= n; j++)
        {
            lenergy = pl[j] - pl[i];
            ggold += g[j];
            energy += e[j];
            if( energy >= lenergy && ggold >= mid)return true;
        }
    }

    return false;
}



main()
{

    cin >> n;

    for(int i = 1; i <= n; i++)
    {
        scanf("%lld %lld %lld" , &pl[i] , &g[i] , &e[i]);
        r += g[i];
    }


    while( r - l > 1 )
    {
        int mid = r + l >> 1ll;
        if( check(mid) )
            l = mid;
        else
            r = mid;
    }
        cout << l;

}

Compilation message

divide.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
divide.cpp: In function 'int main()':
divide.cpp:42:56: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
         scanf("%lld %lld %lld" , &pl[i] , &g[i] , &e[i]);
                                  ~~~~~~                ^
divide.cpp:42:56: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
divide.cpp:42:56: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
divide.cpp:49:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid = r + l >> 1ll;
                   ~~^~~
divide.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld" , &pl[i] , &g[i] , &e[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Incorrect 1 ms 520 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 524 KB Output is correct
2 Correct 2 ms 536 KB Output is correct
3 Correct 4 ms 616 KB Output is correct
4 Correct 6 ms 660 KB Output is correct
5 Incorrect 2 ms 672 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 700 KB Output is correct
2 Correct 4 ms 828 KB Output is correct
3 Incorrect 719 ms 1100 KB Output isn't correct
4 Halted 0 ms 0 KB -