답안 #91054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91054 2018-12-26T04:39:09 Z Aydarov03 금 캐기 (IZhO14_divide) C++14
0 / 100
24 ms 704 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);
    }

    for(int now = 1; now <= n; now++)
    {
        int gold = 0 , place = p[now].fr;

        for(int i = now; i <= n; i++)
        {
//            cout << place << " " << gold << endl;

            gold += p[i].sc.fr;
            if( !used[i] )
            {
                if( place + ( p[i].sc.sc - (place - p[i].fr) ) >= p[i+1].fr )
                {
                    place += ( p[i].sc.sc - (place - p[i].fr) );
                    used[i] = 1;
                    continue;
                }
                else if( place + ( p[i].sc.sc - (place - p[i].fr) ) + p[i+1].sc.sc >= p[i+1].fr )
                {
                    place = p[i+1].fr;
                    used[i] = used[i+1] = 1;
                    continue;
                }
                else
                    break;
            }
            else
            {
                if( p[i+1].fr - p[i+1].sc.sc <= place )
                {
                    used[i+1] = 1;
                    place = p[i+1].fr;
                }
                else
                    break;
            }
        }
        ans = max( ans , gold );
        memset( used , 0 , sizeof(used) );
    }

    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);
                                                              ^
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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 704 KB Output is correct
6 Correct 2 ms 704 KB Output is correct
7 Incorrect 2 ms 704 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 704 KB Output isn't correct
2 Halted 0 ms 0 KB -