Submission #832529

#TimeUsernameProblemLanguageResultExecution timeMemory
832529AkramElOmraniHorses (IOI15_horses)C++17
0 / 100
11 ms8316 KiB
#include <stdio.h> #include <stdlib.h> #include <bits/stdc++.h> using namespace std; #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt") #define ll long long template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; } void dbg_out() { cerr << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); } #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__); const int mod = 1e9 + 7; void max_self(int& a, int b) { a = max(a, b); } int add(int a, int b) { a += b; if(a > mod) { a -= mod; } return a; } int mul(int a, int b) { a = (ll)(a * b) % mod; return a; } const int N = 1e3 + 1; int n; int x[N], y[N]; int solve() { // you have only one day to sell in find that day vector<int> ord(n); iota(ord.begin(), ord.end(), 0); vector<double> pref; pref.push_back(0); vector<int> prod; prod.push_back(1); for(int i = 0; i < n; ++i) { pref.push_back(pref.back() + log10(x[i])); prod.push_back(mul(prod.back(), x[i])); } sort(ord.begin(), ord.end(), [&](int i, int j) { if(i < j) { return pref[j + 1] - pref[i + 1] + log10(y[j]) < log10(y[i]); } else { return pref[i + 1] - pref[j + 1] + log10(y[i]) < log10(y[j]); } }); return mul(prod[ord[0] + 1], y[ord[0]]); } int init(int n_, int x_[], int y_[]) { n = n_; for(int i = 0; i < n; ++i) { x[i] = x_[i]; y[i] = y_[i]; } return solve(); } int updateX(int pos, int val) { x[pos] = val; return solve(); } int updateY(int pos, int val) { x[pos] = val; return solve(); } // static char buffer[1024]; // static int currentChar = 0; // static int charsNumber = 0; // static inline int read() { // if (charsNumber < 0) { // exit(1); // } // if (!charsNumber || currentChar == charsNumber) { // charsNumber = (int)fread(buffer, sizeof(buffer[0]), sizeof(buffer), stdin); // currentChar = 0; // } // if (charsNumber <= 0) { // return -1; // } // return buffer[currentChar++]; // } // static inline int readInt() { // int x; cin >> x; // return x; // } // int main() { // int N; // N = readInt(); // int *X = (int *)malloc(sizeof(int) * (unsigned int)N); // int *Y = (int *)malloc(sizeof(int) * (unsigned int)N); // for (int i = 0; i < N; i++) { // X[i] = readInt(); // } // for (int i = 0; i < N; i++) { // Y[i] = readInt(); // } // printf("%d\n", init(N, X, Y)); // int M; // M = readInt(); // for (int i = 0; i < M; i++) { // int type; // type = readInt(); // int pos; // pos = readInt(); // int val; // val = readInt(); // if (type == 1) { // printf("%d\n", updateX(pos, val)); // } else if (type == 2) { // printf("%d\n", updateY(pos, val)); // } // } // return 0; // }
#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...