Submission #91127

# Submission time Handle Problem Language Result Execution time Memory
91127 2018-12-26T10:30:55 Z Aydarov03 Divide and conquer (IZhO14_divide) C++14
48 / 100
1000 ms 1656 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int x[N] , g[N] , e[N];
int n;
int maxg;
int ans;
int l , r;

inline void check()
{
    int gold;
    int lenergy;
    int genergy;

    for(int i = 1; i <= n; i++)
    {
        gold = 0;
        lenergy = 0;
        genergy = 0;
        for(int j = i; j <= n; j++)
        {
            gold += g[j];
            lenergy = x[j] - x[i];
            genergy += e[j];
            if( genergy >= lenergy )
            {
                ans = max( gold , ans );
            }
        }
    }

    cout << ans;
}




main()
{
    scanf("%lld" , &n);

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

    check();

}

Compilation message

divide.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
divide.cpp: In function 'int main()':
divide.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld" , &n);
     ~~~~~^~~~~~~~~~~~~
divide.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld" , &x[i] , &g[i] , &e[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 484 KB Output is correct
9 Correct 2 ms 540 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 680 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
3 Correct 2 ms 680 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 3 ms 680 KB Output is correct
6 Correct 3 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 3 ms 732 KB Output is correct
10 Correct 4 ms 732 KB Output is correct
11 Correct 16 ms 732 KB Output is correct
12 Correct 17 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 732 KB Output is correct
2 Correct 57 ms 736 KB Output is correct
3 Correct 69 ms 864 KB Output is correct
4 Execution timed out 1069 ms 1656 KB Time limit exceeded
5 Halted 0 ms 0 KB -