Submission #311728

#TimeUsernameProblemLanguageResultExecution timeMemory
311728mohamedsobhi777송금 (JOI19_remittance)C++14
100 / 100
856 ms28792 KiB
#include<bits/stdc++.h> #pragma GCC optimize("-Ofast") #pragma GCC optimize("trapv") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-funroll-loops") #define I inline void #define S struct #define vi vector<int> #define vii vector<pair<int,int>> #define pii pair<int,int> #define pll pair<ll,ll> using namespace std ; using ll = long long ; using ld = long double ; const int N = 1e6 + 7 , mod = 1e9 + 7 ; const ll inf = 2e18 ; // How interesting! int n ; vector<int> a(N , 0) , b(N , 0) ; int main(){ ios_base::sync_with_stdio(0) ; cin.tie(0) ; //freopen("in.in" , "r" , stdin) ; cin >> n; for(int i = 0 ; i < n ; ++ i){ cin >> a[i] >> b[i] ; } for(int k = 0 ; k < 100 ; ++ k){ for(int i = 0 ;i < n ; ++ i){ if(a[i] > b[i] && a[i] > 1){ int c = (a[i] - b[i] + 1) >> 1 ; if(c * 2 > a[i]) c-- ; a[i] -= c * 2 ; a[(i+1)%n]+=c ; } } if(a == b) return cout<<"Yes" , 0 ; } cout<<"No" ; return 0 ; } /* - bounds sir (segtree = 4N, eulerTour = 2N, ...) - a variable defined twice? - will overflow? - is it a good complexity? - don't mess up indices (0-indexed vs 1-indexed) - reset everything between testcases. */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...