제출 #1010672

#제출 시각아이디문제언어결과실행 시간메모리
1010672Ice_man송금 (JOI19_remittance)C++14
0 / 100
1 ms464 KiB
/** ____ ____ ____ __________________ ____ ____ ____ ||I || ||c || ||e || || || ||M || ||a || ||n || ||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__|| |/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\| */ #include <iostream> #include <chrono> #include <vector> #define maxn 100005 #define maxlog 20 #define INF 1000000010 #define LINF 1000000000000000005 #define endl '\n' #define pb(x) push_back(x) #define X first #define Y second #define control cout<<"passed"<<endl; #pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math") #pragma GCC target("avx2") using namespace std; typedef pair <int, int> pii; typedef long long ll; typedef pair <ll, ll> pll; typedef pair <int, ll> pil; typedef pair <ll, int> pli; typedef long double ld; std::chrono::high_resolution_clock::time_point startT, currT; constexpr double TIME_MULT = 1; double timePassed() { using namespace std::chrono; currT = high_resolution_clock::now(); double time = duration_cast<duration<double>>(currT - startT).count(); return time * TIME_MULT; } int v[maxn]; ll n, a[maxn], b[maxn]; void read() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; for(int i = 1; i <= n - 1; i++) v[i] = i + 1; v[n] = 1; } void make_step() { for(int i = 1; i <= n; i++) { if(a[i] <= b[i]) continue; ll money; if(a[i] - b[i] % 2 == 1) money = (a[i] - b[i] + 1) / 2; else money = (a[i] - b[i]) / 2; a[i] -= money * 2; a[v[i]] += money; } /**for(int i = 1; i <= 1; i++) { if(a[i] <= b[i]) continue; ll money; if(a[i] - b[i] % 2 == 1) money = (a[i] - b[i] + 1LL) / 2; else money = (a[i] - b[i]) / 2; a[i] -= money * 2; a[v[i]] += money; }*/ } void solve() { int constant = 1e5; while(constant--) { make_step(); bool lamp = true; for(int i = 1; i <= n; i++) if(a[i] != b[i]) lamp = false; if(lamp == true) { cout << "Yes" << endl; return; } } cout << "No" << endl; } int main() { /**#ifdef ONLINE_JUDGE freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #endif*/ ios_base::sync_with_stdio(false); cin.tie(nullptr); ///startT = std::chrono::high_resolution_clock::now(); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...