Submission #53481

# Submission time Handle Problem Language Result Execution time Memory
53481 2018-06-30T05:46:27 Z !?!?(#2015) Garage (IOI09_garage) C++11
100 / 100
5 ms 612 KB
#include<bits/stdc++.h>
using namespace std;
int N, M;
int R[101010];
int W[101010]; //R*W
int pos[101010];
queue<int> Q;
int main()
{
    scanf("%d%d", &N, &M);
    for(int i=1; i<=N; ++i)
        scanf("%d", R+i);
    for(int i=1; i<=M; ++i)
        scanf("%d", W+i);
    int ans = 0;
    for(int i=0; i<2*M; ++i)
    {
        int t; scanf("%d", &t);
        if(t>0)
            Q.push(t);
        else
        {
            for(int i=1; i<=N; ++i)
                if(pos[i] == -t) pos[i] = 0;
        }
        for(int i=1; i<=N; ++i)
        {
            if(pos[i] == 0 && !Q.empty())
            {
                pos[i] = Q.front(); Q.pop();
                ans += R[i] * W[pos[i]];
            }
        }
    }
    printf("%d\n", ans);
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", R+i);
         ~~~~~^~~~~~~~~~~
garage.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", W+i);
         ~~~~~^~~~~~~~~~~
garage.cpp:18:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int t; scanf("%d", &t);
                ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 3 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 3 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 4 ms 592 KB Output is correct
15 Correct 4 ms 592 KB Output is correct
16 Correct 3 ms 612 KB Output is correct
17 Correct 5 ms 612 KB Output is correct
18 Correct 4 ms 612 KB Output is correct
19 Correct 4 ms 612 KB Output is correct
20 Correct 4 ms 612 KB Output is correct