Submission #986504

# Submission time Handle Problem Language Result Execution time Memory
986504 2024-05-20T16:56:32 Z diaabt Remittance (JOI19_remittance) C++14
0 / 100
1 ms 472 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ldb long double
#define db double
#define fin(x) freopen(x,"r",stdin)
#define fout(x) freopen(x,"w",stdout)
#define fo(i,l,r) for(int i=(l);i<=(r);i++)
#define foi(i,l,r) for(int i=(l);i>=(r);i--)
#define el cout<<'\n';
#define cel cerr<<'\n';
#define all(x) x.begin(),x.end()
#define ii pair<int,int>
#define iii pair<int,ii>
#define gb(x,i) (((x)>>(i))&1)
#define mask(i) (1LL<<(i))
#define TIME (1.0 * clock()/CLOCKS_PER_SEC)
using namespace std;
const int N=1e6+5;
const int bl=60;
const ll base=1e9+7;
const ll inf=1e9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll l,ll r)
{
    return l+(1ll*rng()*rng()%(r-l+1)+(r-l+1))%(r-l+1);
}
template<class X,class Y>bool maximize(X &a,Y b)
{
    if(a<b) return a=b,true;
    return false;
}
template<class X,class Y>bool minimize(X &a, Y b)
{
    if(a>b) return a=b,true;
    return false;
}
void add(auto &a,auto b)
{
    a+=b;
    if(a>=base) a-=base;
    if(a<0) a+=base;
}
int n,a[N],b[N];
int main()
{
    #define task "o"
    if(fopen(task".inp","r"))
    {
        fin(task".inp");
        //fout(task".out");
    }
    srand(time(NULL));
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    fo(i,1,n) cin>>a[i]>>b[i];
    fo(i,1,n) if(a[i]>b[i]+1)
    {
        int now=a[i]-b[i];
        if(now%2==0) a[i]=b[i];
        else a[i]=b[i]+1,now--;
        fo(j,i+1,n)
        {
            a[j]+=now/2,now=0;
            if(a[j]>b[j])
            {
                now=a[j]-b[j];
                if(now%2==0) a[j]=b[j];
                else a[j]=b[j]+1,now--;
            }
            if(now==0) break;
        }
        fo(j,1,i-1)
        {
            a[j]+=now/2,now=0;
            if(a[j]>b[j])
            {
                now=a[j]-b[j];
                if(now%2==0) a[j]=b[j];
                else a[j]=b[j]+1,now--;
            }
            if(now==0) break;
        }
        if(now!=0) return cout<<"No",0;
    }
    fo(i,1,n) if(a[i]!=b[i]) return cout<<"No",0;
    cout<<"Yes",el
    cerr<<"Time elapsed: "<<TIME<<" s.\n";
}

Compilation message

remittance.cpp:41:10: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   41 | void add(auto &a,auto b)
      |          ^~~~
remittance.cpp:41:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   41 | void add(auto &a,auto b)
      |                  ^~~~
remittance.cpp: In function 'int main()':
remittance.cpp:9:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define fin(x) freopen(x,"r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~
remittance.cpp:53:9: note: in expansion of macro 'fin'
   53 |         fin(task".inp");
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 472 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -