답안 #567036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567036 2022-05-23T07:27:30 Z Dodo Kitchen (BOI19_kitchen) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back

using namespace std;
const ll mx=1007, INF=1e18L+5;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  ll n,m,k;
  cin>>n>>m>>k;
  ll arr[n];
  for(int i=0;i<n;i++)cin>>arr[i];
  deque<pair<ll,ll>>dq(m);
  ll sum=0;
  for(int i=0;i<m;i++)
  {
    ll x;
    cin>>x;
    dq[i]={x,0};
  }
  for(int i=0;i<n;i++)
  {
    ll s=arr[i];
    while(arr[i]!=0)
    {
      if(dq.size()==0)
      {
        cout<<"Impossible";
        return 0;
      }
      if(dq.front().second==0)
        dq.front().second=1;

      ll x=dq.front().first;
      if(arr[i]>=x)
      {
        arr[i]-=x;
        dq.pop_front();
      }
      else
      {
        dq[0].first-=arr[i];
        arr[i]=0;
      }
    }
  }
  if(dq.front().second==0)
  cout<<0;
  else
  cout<<dq.front().first;
 return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:29:8: warning: unused variable 's' [-Wunused-variable]
   29 |     ll s=arr[i];
      |        ^
kitchen.cpp:20:6: warning: unused variable 'sum' [-Wunused-variable]
   20 |   ll sum=0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -