Submission #950377

# Submission time Handle Problem Language Result Execution time Memory
950377 2024-03-20T09:00:29 Z vjudge1 Remittance (JOI19_remittance) C++17
15 / 100
82 ms 4700 KB
#include <bits/stdc++.h>
 
#pragma optimize("Ofast,unroll-loops")
#pragma target("avx2")
 
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(s) (int)s.size()
#define y1 yy
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define in insert
#define int ll
 
const int MAX=2e5+10;
const int B=500;
const int maxB=1000;
const int N=104;
const int block=450;
const int inf=2e9;  
const int mod=1e9+7;
const int mod1=1e9+9;
const ld eps=1e-9;
 
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,-1,1,-1};
 
int binpow(int a,int n){
  if(!n)return 1;
  if(n%2==1)return a*binpow(a,n-1)%mod;
  int k=binpow(a,n/2);
  return k*k%mod;
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n;
int a[MAX],b[MAX];
 
int r(int i){
  return i%n+1;
}
 
int bit(int i,int j){
  return (i>>j)&1;
}
 
int p[MAX],c[MAX];
int sum=0;
bool ok=0;
 
bool check(){
  int na[10];
  int cc[10];
  int f=0,cnt=0;
  for(int i=1;i<=n;i++)na[i]=a[i],cc[i]=c[i],cnt+=c[i];
  while(f<=sum&&cnt>=0){
    for(int i=1;i<=n;i++){
      while(cc[i]&&na[i]>=2){
        na[i]-=2;
        na[r(i)]++;
        cnt--;
        cc[i]--;
      }
    }
    f++;
  }
  bool ok=1;
  for(int i=1;i<=n;i++){
    if(na[i]!=b[i])ok=0;
  }
  if(ok)return 1;
  return 0;
}
 
void calc(int i){
  if(i==n+1){
    ok|=check();
    return;
  }
  c[i]=0;
  for(c[i]=0;c[i]<=5;c[i]++){
    calc(i+1);
  }
}
 
void solve(){
  cin>>n;
  int mn=inf;
  for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i];
    sum+=a[i]-b[i];
    mn=min(mn,a[i]);
  }
  if(sum<0){                                                    
    cout<<"No"<<"\n";
    return;
  }
  while(sum-n>=n&&mn){
    sum-=n;
    mn--;
    for(int i=1;i<=n;i++)a[i]-=1;
  }
  calc(1);
  if(ok){
    cout<<"Yes\n";
    return;
  }
  cout<<"No\n";
}
 
signed main(){
  // freopen("triangles.in","r",stdin);
  // freopen("triangles.out","w",stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // prec();
  int t=1;
  // cin>>t;
  while(t--){
    solve();
  }
}

Compilation message

remittance.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize("Ofast,unroll-loops")
      | 
remittance.cpp:4: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    4 | #pragma target("avx2")
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2480 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 28 ms 2396 KB Output is correct
7 Correct 31 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 16 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 3 ms 2392 KB Output is correct
15 Correct 19 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 4 ms 2492 KB Output is correct
19 Correct 15 ms 2520 KB Output is correct
20 Correct 35 ms 2396 KB Output is correct
21 Correct 82 ms 2500 KB Output is correct
22 Correct 27 ms 2396 KB Output is correct
23 Correct 47 ms 2504 KB Output is correct
24 Correct 52 ms 2392 KB Output is correct
25 Correct 52 ms 2392 KB Output is correct
26 Correct 23 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 8 ms 2396 KB Output is correct
29 Correct 56 ms 2396 KB Output is correct
30 Correct 54 ms 2396 KB Output is correct
31 Correct 23 ms 2392 KB Output is correct
32 Correct 31 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2480 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 28 ms 2396 KB Output is correct
7 Correct 31 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 16 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 3 ms 2392 KB Output is correct
15 Correct 19 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 4 ms 2492 KB Output is correct
19 Correct 15 ms 2520 KB Output is correct
20 Correct 35 ms 2396 KB Output is correct
21 Correct 82 ms 2500 KB Output is correct
22 Correct 27 ms 2396 KB Output is correct
23 Correct 47 ms 2504 KB Output is correct
24 Correct 52 ms 2392 KB Output is correct
25 Correct 52 ms 2392 KB Output is correct
26 Correct 23 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 8 ms 2396 KB Output is correct
29 Correct 56 ms 2396 KB Output is correct
30 Correct 54 ms 2396 KB Output is correct
31 Correct 23 ms 2392 KB Output is correct
32 Correct 31 ms 2396 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Runtime error 3 ms 4700 KB Execution killed with signal 6
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2480 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 28 ms 2396 KB Output is correct
7 Correct 31 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 16 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 3 ms 2392 KB Output is correct
15 Correct 19 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 4 ms 2492 KB Output is correct
19 Correct 15 ms 2520 KB Output is correct
20 Correct 35 ms 2396 KB Output is correct
21 Correct 82 ms 2500 KB Output is correct
22 Correct 27 ms 2396 KB Output is correct
23 Correct 47 ms 2504 KB Output is correct
24 Correct 52 ms 2392 KB Output is correct
25 Correct 52 ms 2392 KB Output is correct
26 Correct 23 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 8 ms 2396 KB Output is correct
29 Correct 56 ms 2396 KB Output is correct
30 Correct 54 ms 2396 KB Output is correct
31 Correct 23 ms 2392 KB Output is correct
32 Correct 31 ms 2396 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Runtime error 3 ms 4700 KB Execution killed with signal 6
35 Halted 0 ms 0 KB -