제출 #142574

#제출 시각아이디문제언어결과실행 시간메모리
142574andreiomdDetecting Molecules (IOI16_molecules)C++11
10 / 100
5 ms504 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; const int NMAX = 2e5 + 5; int N, A[NMAX]; long long dp[NMAX]; static long long Sum (int Left, int Right) { if(Left > Right) return 0LL; return dp[Right] - dp[Left - 1]; } vector < int > find_subset (int l, int u, vector < int > w) { int N = (int)w.size(); for(int i = 0; i < N; ++i) A[i + 1] = w[i]; for(int i = 1; i <= N; ++i) dp[i] = dp[i - 1] + 1LL * A[i]; bool Ok = false; int Left = 1, Right = 0; for(Left = 1, Right = 0; Left <= N; ++Left) { while(Sum(Left, Right) < l) ++Right; if(Sum(Left, Right) >= l && Sum(Left, Right) <= u) { Ok = true; break; } while(Sum(Left, Right) > u) ++Left; if(Sum(Left, Right) >= l && Sum(Left, Right) <= u) { Ok = true; break; } } vector < int > Sol; if(Ok) { for(int i = Left; i <= Right; ++i) Sol.push_back(i - 1); return Sol; } Left = 1; Right = 0; for(Left = 1, Right = 0; Left <= N && Right <= N && !Ok; ++Left) { for(int i = 1; i <= 16; ++i) { while(Sum(Left, Right) < l) ++Right; while(Sum(Left, Right) > u) ++Left; if(Sum(Left, Right) >= l && Sum(Left, Right) <= u) { Ok = true; break; } } } if(Ok) { for(int i = Left; i <= Right; ++i) Sol.push_back(i - 1); return Sol; } return Sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...