Submission #91119

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

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

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 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -