Submission #248771

# Submission time Handle Problem Language Result Execution time Memory
248771 2020-07-13T10:44:02 Z uacoder123 Garage (IOI09_garage) C++14
40 / 100
1000 ms 512 KB
 #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
 
typedef int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test=1;
  for(;test>0;--test)
  {
    int n,m,ans=0;
    cin>>n>>m;
    int r[n+1],w[m+1],pos[m+1]={};
    set<int>p;
    for(int i=1;i<=n;++i)
    {
      cin>>r[i];
      p.insert(i);
    }
    for(int i=1;i<=m;++i)
      cin>>w[i];
    for(int i=0;i<2*m;++i)
    {
      int f;
      cin>>f;
      if(f>0)
      {
        int fp=(*p.begin());
        p.erase(p.begin());
        pos[f]=fp;
        ans+=r[fp]*w[f];
      }
      else
      {
        p.insert(pos[-f]);
        pos[-f]=0;
      }
    }
    cout<<ans<<endl;
  }
  return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Execution timed out 1094 ms 384 KB Time limit exceeded
3 Correct 0 ms 384 KB Output is correct
4 Execution timed out 1093 ms 384 KB Time limit exceeded
5 Correct 0 ms 384 KB Output is correct
6 Execution timed out 1085 ms 384 KB Time limit exceeded
7 Correct 0 ms 384 KB Output is correct
8 Execution timed out 1093 ms 384 KB Time limit exceeded
9 Correct 0 ms 512 KB Output is correct
10 Execution timed out 1093 ms 384 KB Time limit exceeded
11 Correct 1 ms 384 KB Output is correct
12 Execution timed out 1094 ms 384 KB Time limit exceeded
13 Correct 1 ms 384 KB Output is correct
14 Execution timed out 1091 ms 384 KB Time limit exceeded
15 Correct 1 ms 384 KB Output is correct
16 Execution timed out 1090 ms 384 KB Time limit exceeded
17 Execution timed out 1091 ms 384 KB Time limit exceeded
18 Execution timed out 1093 ms 384 KB Time limit exceeded
19 Execution timed out 1097 ms 384 KB Time limit exceeded
20 Execution timed out 1094 ms 384 KB Time limit exceeded