제출 #851109

#제출 시각아이디문제언어결과실행 시간메모리
851109oneloveforeverOvertaking (IOI23_overtaking)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll int64
#define x first
#define y second
const int MAXN=1e3+7;
set<pair<long long ,long long> >place[MAXN];
ll M,X;
vector<ll>S;
void init(int L,int N,vector<long long>T,vector<int>W,int _X,int _M,vector<int>_S)
{
    M=_M;
    X=_X;
    S=_S;
    vector<pair<long long,long long> >block;
    for(int i=0;i<=N-1;i++)block.push_back({W[i],T[i]});
    sort(block.begin(),block.end());
    for(int i=0;i<=M-1;i++)place[i].insert(make_pair(0,0));
    for(int i=(int)block.size()-1;i>=0;i--)
    {
        long long Time=block[i].y;
        long long C=block[i].x;
        for(int cnt=1;cnt<=M-1;cnt++)
        {
            auto pre=prev(place[cnt].lower_bound(make_pair(Time,0)));
            long long newTime=max(pre->y,Time+C*(S[cnt]-S[cnt-1]));
            place[cnt].insert(make_pair(Time,newTime));
            Time=newTime;
        }
    }
}
long long arrival_time(long long Time)
{
    for(int cnt=1;cnt<=M-1;cnt++)
    {
        auto pre=prev(place[cnt].lower_bound(make_pair(Time,0)));
        long long newTime=max(pre->y,Time+X*(S[cnt]-S[cnt-1]));
        Time=newTime;
    }
    return Time;
}
/*int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int L,N;
    vector<long long>T;
    vector<int>W;
    int X,M;
    vector<int>S;
    cin>>L>>N;
    for(int i=1;i<=N;i++)
    {
        long long value;
        cin>>value;
        T.push_back(value);
    }
    for(int i=1;i<=N;i++)
    {
        long long value;
        cin>>value;
        W.push_back(value);
    }
    cin>>X>>M;
    for(int i=1;i<=M;i++)
    {
        int value;
        cin>>value;
        S.push_back(value);
    }
    init(L,N,T,W,X,M,S);
    int Time;
    cin>>Time;
    cout<<arrival_time(Time);
}*/

컴파일 시 표준 에러 (stderr) 메시지

overtaking.cpp:3:12: error: 'int64' does not name a type; did you mean 'int64_t'?
    3 | #define ll int64
      |            ^~~~~
overtaking.cpp:8:1: note: in expansion of macro 'll'
    8 | ll M,X;
      | ^~
overtaking.cpp:3:12: error: 'int64' was not declared in this scope; did you mean 'int64_t'?
    3 | #define ll int64
      |            ^~~~~
overtaking.cpp:9:8: note: in expansion of macro 'll'
    9 | vector<ll>S;
      |        ^~
overtaking.cpp:9:10: error: template argument 1 is invalid
    9 | vector<ll>S;
      |          ^
overtaking.cpp:9:10: error: template argument 2 is invalid
overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:12:5: error: 'M' was not declared in this scope
   12 |     M=_M;
      |     ^
overtaking.cpp:13:5: error: 'X' was not declared in this scope
   13 |     X=_X;
      |     ^
overtaking.cpp:14:7: error: cannot convert 'std::vector<int>' to 'int' in assignment
   14 |     S=_S;
      |       ^~
      |       |
      |       std::vector<int>
overtaking.cpp:26:51: error: invalid types 'int[int]' for array subscript
   26 |             long long newTime=max(pre->y,Time+C*(S[cnt]-S[cnt-1]));
      |                                                   ^
overtaking.cpp:26:58: error: invalid types 'int[int]' for array subscript
   26 |             long long newTime=max(pre->y,Time+C*(S[cnt]-S[cnt-1]));
      |                                                          ^
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:34:24: error: 'M' was not declared in this scope
   34 |     for(int cnt=1;cnt<=M-1;cnt++)
      |                        ^
overtaking.cpp:37:43: error: 'X' was not declared in this scope
   37 |         long long newTime=max(pre->y,Time+X*(S[cnt]-S[cnt-1]));
      |                                           ^
overtaking.cpp:37:47: error: invalid types 'int[int]' for array subscript
   37 |         long long newTime=max(pre->y,Time+X*(S[cnt]-S[cnt-1]));
      |                                               ^
overtaking.cpp:37:54: error: invalid types 'int[int]' for array subscript
   37 |         long long newTime=max(pre->y,Time+X*(S[cnt]-S[cnt-1]));
      |                                                      ^