답안 #136155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136155 2019-07-24T20:10:20 Z PedroBigMan 송금 (JOI19_remittance) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF ((ll) pow(2,63) -1)
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

bool ped(ll N, vector<ll> A, vector<ll> B)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    bool al0=true;
    REP(i,0,N)
    {
        if(B[i]>0) {al0=false;};
    }
    vector<ll> dif; REP(i,0,N) {dif.pb(A[i]-B[i]);}
    bool changed; ll mx,pos,pas;
    while(1>0)
    {
        Out(dif);
        changed=false; mx=1;
        REP(i,0,N) 
        {
            if(dif[i]>mx) {mx=dif[i]; pos=i; changed=true;}
        }
        if(!changed) 
        {
            sort(dif.begin(),dif.end()); 
            if(dif[0]==dif[N-1] && dif[0]==0) {return true;}
            if(dif[0]==dif[N-1] && dif[0]==1 && !al0) {return true;}
            return false;
        }
        pas=(ll) floor((ld) dif[pos]/2);dif[pos]%=2;
        if(pos<=N-2) 
        {
            dif[pos+1]+=pas;
        }
        else
        {
            dif[0]+=pas;
        }
    }
}


int main()
{
    ll s; vector<ll> A; vector<ll> B;
    cin>>s; In(A,s); In(B,s); 
    if(ped(s,A,B)) {cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}
    return 0;
}

Compilation message

remittance.cpp: In function 'void Out(std::vector<long long int>)':
remittance.cpp:13:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
remittance.cpp:22:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
remittance.cpp:22:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -