답안 #91068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91068 2018-12-26T06:28:53 Z Aydarov03 금 캐기 (IZhO14_divide) C++14
0 / 100
38 ms 604 KB
#include <bits/stdc++.h>
#define int long long
#define fr first
#define sc second
using namespace std;

pair<int , pair<int,int> > p[100005];
bool used[100005];
int ans;

main()
{
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); // place , gold , energy
    }



    for(int j = 1; j <= n; j++)
    {
        int start =  p[j].fr , en = start + p[j].sc.sc , gold =  p[j].sc.fr;
        for(int now = j; now <= n; now++)
        {
            bool in = false;
            int ls = 0 , fr;

            for( int i = now+1; i <= n; i++)
            {
                if( p[i].fr >= start &&  p[i].fr <= en )
                {
                    in = true;
                    if(  p[i].fr + p[i].sc.sc > ls  )
                    {
                        ls = p[i].fr + p[i].sc.sc;
                        fr = p[i].fr;
                        now = i;
                    }

                    gold += p[i].sc.fr;
                }
                else
                    break;
            }



            if(in && ls > en)
            {
                start = fr , en = ls;
                now--;
            }

            else if( p[now + 1 ].fr - p[now + 1 ].sc.sc <= en )
            {
                start = en = p[now+1].fr;
                gold += p[now+1].sc.fr;
            }

        }
        ans = max( ans , gold );
    }
    cout << ans;

}

Compilation message

divide.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
divide.cpp: In function 'int main()':
divide.cpp:18:62: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); // place , gold , energy
                                                              ^
divide.cpp:18:62: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
divide.cpp:18:62: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
divide.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); // place , gold , energy
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:33:17: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 if( p[i].fr >= start &&  p[i].fr <= en )
                 ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Incorrect 2 ms 488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -