Submission #295794

#TimeUsernameProblemLanguageResultExecution timeMemory
295794GajowyRemittance (JOI19_remittance)C++14
100 / 100
259 ms35320 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define mp make_pair #define eb emplace_back #define pb push_back #define e1 first #define e2 second #define int int_fast32_t #define uint uint_fast64_t #define ll int_fast64_t #define ull uint_fast64_t #define int16 int_fast16_t #define uint16 uint_fast16_t #define int32 int_fast32_t #define uint32 uint_fast32_t #define int64 int_fast64_t #define uint64 uint_fast64_t #define ld long double #define float long double #define size(x) (int)x.size() #define satori int testCases; cin>>testCases; while(testCases--) #define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define all(r) begin(r),end(r) #define rall(r) rbegin(r),rend(r) #define time chrono::high_resolution_clock().now().time_since_epoch().count() #define elapsed(__begin,__end) (__end-__begin)/CLOCKS_PER_SEC typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; float pi=3.14159265358979323846; const int MAXN=1e6+10; ll a[MAXN],b[MAXN],x; int32_t main() { fastio; int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i]>>b[i]; while(true) { for(int i=0;i<n;i++) if(a[i]>b[i]&&a[i]>1ll) { x=(a[i]-b[i]+1ll)/2ll; if(2ll*x>a[i]) x--; a[(i+1)%n]+=x,a[i]-=2ll*x; } bool over=false; for(int i=0;i<n;i++) if(a[i]>b[i]&&a[i]>1) over=true; if(!over) break; } for(int i=0;i<n;i++) if(a[i]!=b[i]) { cout<<"No\n"; return 0; } cout<<"Yes\n"; }

Compilation message (stderr)

remittance.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
remittance.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...