제출 #1252460

#제출 시각아이디문제언어결과실행 시간메모리
12524603m17Garage (IOI09_garage)C++20
100 / 100
1 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define int long long
#define ii pair<int , int>

const int Nmax = 1e6 + 5;
const int MOD = 1e9 + 7;
const int LogN = 17;

int n , m , z;
int r[Nmax] , w[Nmax] , idx[Nmax] , idxCar[Nmax];
int Ans;
queue <int> Q;

main()
{
    cin >> n >> m;
    for (int i = 1 ; i <= n ; i++)
    cin >> r[i];

    for (int i = 1 ; i <= m ; i++)
    cin >> w[i];

    for (int i = 1 ; i <= 2 * m ; i++)
    {
        int x;
        cin >> x;
        if(x > 0) Q.push(x);
        else
        {
            x = abs(x);
            idx[idxCar[x]] = false;
        }

        if(!Q.empty())
        {
            z = Q.front();
            //cout << z << '\n';
            for (int j = 1 ; j <= n ; j++)
            if(!idx[j])
            {
                Q.pop();
                idxCar[z] = j;
                idx[j] = true;
                Ans += r[j] * w[z];
                //cout << Ans << ' ';
                break;
            }
        }
    }

    cout << Ans;
}
/*
3 4
2
3
5
200
100
300
800
3
2
-3
1
4
-4
-2
-1

2 4
5
2
100
500
1000
2000
3
1
2
4
-1
-3
-2
-4
*/

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

garage.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...