problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { // 100要素の配列で初期化 int n; cin >> n; vector<int> vec(n); string a = "YES"; // 100個の入力を受け取る for (int i = 0; i < n; i++) { cin >> vec.at(i); } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (vec.at(i) == vec.at(j)) a = "NO"; } } cout << a << endl; }
#include <bits/stdc++.h> using namespace std; int main() { // 100要素の配列で初期化 int n; cin >> n; vector<int> vec(n); string a = "YES"; // 100個の入力を受け取る for (int i = 0; i < n; i++) { cin >> vec.at(i); } sort(vec.begin(), vec.end()); for (int i = 1; i < n; i++) { if (vec.at(i) == vec.at(i - 1)) a = "NO"; } cout << a << endl; }
replace
13
18
13
17
TLE
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } bool ans = true; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a.at(i) == a.at(j)) { ans = false; } } } if (ans) { cout << "YES" << endl; } else { cout << "NO" << endl; } }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } bool ans = true; sort(a.begin(), a.end()); for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) { ans = false; } } if (ans) { cout << "YES" << endl; } else { cout << "NO" << endl; } }
replace
17
22
17
21
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> #define FIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define PI 3.141592653589793238462643383279502884L #define make_unique(vec) \ vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end()))) #define Sort(vec) sort(vec.begin(), vec.end()) #define RSort(vec) sort(vec.rbegin(), vec.rend()) #define endl "\n" #define tr1(i) cout << i << endl; #define tr2(i, j) cout << i << " " << j << endl; #define tr3(i, j, k) cout << i << " " << j << " " << k << endl; #define vvi vector<vector<int>> #define vvl vector<vector<ll>> #define all(st) st.begin(), st.end() #define vpl vector<pair<ll, ll>> #define vpi vector<pair<int, int>> #define pi pair<int, int> #define pl pair<ll, ll> #define al vector<list<int>> #define vs vector<string> #define vi vector<int> #define vb vector<bool> #define vl vector<ll> #define vc vector<char> #define rep(i, l, r) for (int i = l; i < r; i++) #define repit(st) for (auto it = st.begin(); it != st.end(); it++) #define ull unsigned long long int #define eb emplace_back #define pb push_back #define ll long long int #define minf -(1e18) #define inf 1e18 #define f first #define se second #define mod 1000000007 using namespace std; ll mi(ll n, ll m) { ll pw = n % m; ll ex = m - 2; ll ans = 1; while (ex) { if (ex & 1) ans = ans * pw % m; pw = pw * pw % m; ex >>= 1; } return ans % mod; } ll pw(ll a, ll n) { ll pw = a % mod; ll ex = n; ll ans = 1; while (ex) { if (ex & 1) ans = ans * pw % mod; pw = pw * pw % mod; ex >>= 1; } return ans % mod; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) { os << t << " "; } os << '\n'; return os; } void show(ll x) { cout << x << " "; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll max(ll a, ll b) { return a > b ? a : b; } ll min(ll a, ll b) { return a < b ? a : b; } ll Abs(ll x) { return x > 0 ? x : (-x); } ll Ceil(ll a, ll b) { return a / b + (a % b != 0); } #define bs binary_search // #define int long long #define lb lower_bound #define mkp make_pair // #define d double void solve() { int n; cin >> n; vi vec(n); cin >> n; set<int> st; rep(i, 0, n) st.insert(vec[i]); if (st.size() == n) cout << "YES" << endl; else cout << "NO" << endl; } int32_t main() { int t = 1; // cin>>t; while (t--) { solve(); } }
#include <bits/stdc++.h> #define FIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define PI 3.141592653589793238462643383279502884L #define make_unique(vec) \ vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end()))) #define Sort(vec) sort(vec.begin(), vec.end()) #define RSort(vec) sort(vec.rbegin(), vec.rend()) #define endl "\n" #define tr1(i) cout << i << endl; #define tr2(i, j) cout << i << " " << j << endl; #define tr3(i, j, k) cout << i << " " << j << " " << k << endl; #define vvi vector<vector<int>> #define vvl vector<vector<ll>> #define all(st) st.begin(), st.end() #define vpl vector<pair<ll, ll>> #define vpi vector<pair<int, int>> #define pi pair<int, int> #define pl pair<ll, ll> #define al vector<list<int>> #define vs vector<string> #define vi vector<int> #define vb vector<bool> #define vl vector<ll> #define vc vector<char> #define rep(i, l, r) for (int i = l; i < r; i++) #define repit(st) for (auto it = st.begin(); it != st.end(); it++) #define ull unsigned long long int #define eb emplace_back #define pb push_back #define ll long long int #define minf -(1e18) #define inf 1e18 #define f first #define se second #define mod 1000000007 using namespace std; ll mi(ll n, ll m) { ll pw = n % m; ll ex = m - 2; ll ans = 1; while (ex) { if (ex & 1) ans = ans * pw % m; pw = pw * pw % m; ex >>= 1; } return ans % mod; } ll pw(ll a, ll n) { ll pw = a % mod; ll ex = n; ll ans = 1; while (ex) { if (ex & 1) ans = ans * pw % mod; pw = pw * pw % mod; ex >>= 1; } return ans % mod; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) { os << t << " "; } os << '\n'; return os; } void show(ll x) { cout << x << " "; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll max(ll a, ll b) { return a > b ? a : b; } ll min(ll a, ll b) { return a < b ? a : b; } ll Abs(ll x) { return x > 0 ? x : (-x); } ll Ceil(ll a, ll b) { return a / b + (a % b != 0); } #define bs binary_search // #define int long long #define lb lower_bound #define mkp make_pair // #define d double void solve() { int n; cin >> n; vi vec(n); cin >> vec; set<int> st(all(vec)); // rep(i,0,n) st.insert(vec[i]); if ((st.size()) == n) cout << "YES" << endl; else cout << "NO" << endl; } int32_t main() { int t = 1; // cin>>t; while (t--) { solve(); } }
replace
91
95
91
95
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef unsigned long long ull; typedef pair<int, int> P; int main() { long n; cin >> n; vector<long> a(n); bool IsNotUnique = false; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (a[i] == a[j]) { IsNotUnique = true; break; } } if (IsNotUnique) break; } if (IsNotUnique) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef unsigned long long ull; typedef pair<int, int> P; int main() { long n; cin >> n; vector<long> a(n); bool IsNotUnique = false; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); // ソート a.erase(unique(a.begin(), a.end()), a.end()); // 重複を削除 if (a.size() != n) { IsNotUnique = true; } if (IsNotUnique) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
replace
16
25
16
22
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a.at(i); } sort(a.begin(), a.end()); bool sta = false; for (int i = 0; i < n; i++) { if (a.at(i) == a.at(i + 1)) { cout << "NO" << endl; sta = true; break; } } if (!sta) { cout << "YES" << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a.at(i); } sort(a.begin(), a.end()); bool sta = false; for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) { cout << "NO" << endl; sta = true; break; } } if (!sta) { cout << "YES" << endl; } return 0; }
replace
15
16
15
16
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)
p02779
C++
Runtime Error
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = 1; i <= (int)(n); i++) #define dunk(n) cout << n << endl #define all(a) (a).begin(), (a).end() typedef pair<int, int> P; typedef long long ll; int main() { int n; cin >> n; vector<ll> num(n); rep(i, n) cin >> num[i]; sort(all(num)); rrep(i, n) { if (num[i - 1] == num[i]) { dunk("NO"); return 0; } } dunk("YES"); return 0; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = 1; i < (int)(n); i++) #define dunk(n) cout << n << endl #define all(a) (a).begin(), (a).end() typedef pair<int, int> P; typedef long long ll; int main() { int n; cin >> n; vector<ll> num(n); rep(i, n) cin >> num[i]; sort(all(num)); rrep(i, n) { if (num[i - 1] == num[i]) { dunk("NO"); return 0; } } dunk("YES"); return 0; }
replace
4
5
4
5
-6
/usr/include/c++/12/debug/vector:442: In function: std::debug::vector<_Tp, _Allocator>::reference std::debug::vector<_Tp, _Allocator>::operator[](size_type) [with _Tp = long long int; _Allocator = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int] Error: attempt to subscript container with out-of-bounds index 5, but container only holds 5 elements. Objects involved in the operation: sequence "this" @ 0x7ffe18e11fd0 { type = std::debug::vector<long long, std::allocator<long long> >; }
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); bool result = true; for (int i = 0; i < n; i++) { cin >> a.at(i); for (int j = 0; j < i; j++) { if (a.at(i) == a.at(j)) { result = false; break; } } } if (result) { cout << "YES" << endl; } else { cout << "NO" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); bool result = true; for (int i = 0; i < n; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) { result = false; break; } } if (result) { cout << "YES" << endl; } else { cout << "NO" << endl; } }
replace
10
15
10
16
TLE
p02779
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int inf = 0x3f3f3f3f; bool ok; char ch; void read(int &x) { for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') ok = 1; for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar()) ; if (ok) x = -x; } void write(int x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) write(x / 10); putchar(x % 10 + '0'); return; } int s[200005]; int main() { int n; cin >> n; while (n--) { int a; cin >> a; if (s[a]) { cout << "NO"; return 0; } s[a] = 1; } cout << "YES"; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int inf = 0x3f3f3f3f; bool ok; char ch; void read(int &x) { for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') ok = 1; for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar()) ; if (ok) x = -x; } void write(int x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) write(x / 10); putchar(x % 10 + '0'); return; } unordered_map<int, int> s; int main() { int n; cin >> n; while (n--) { int a; cin >> a; if (s[a]) { cout << "NO"; return 0; } s[a] = 1; } cout << "YES"; return 0; }
replace
41
42
41
42
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) // #define int long long #define all(v) v.begin(), v.end() #define sortAl(v) sort(all(v)) #define sortAlr(v) \ sort(v.begin(), v.end()); \ reverse(v.begin(), v.end()) #define cout(n) cout << fixed << setprecision(n) #define rep(i, n) for (ll i = 0; i < n; i++) #define REP(i, n) for (ll i = 1; i < n; i++) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++) template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); } template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); } #define mod (ll)(1e9 + 7) #define INF LLONG_MAX signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a[i]; } rep(i, n) { FOR(j, i + 1, n) { if (a[i] == a[j]) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) // #define int long long #define all(v) v.begin(), v.end() #define sortAl(v) sort(all(v)) #define sortAlr(v) \ sort(v.begin(), v.end()); \ reverse(v.begin(), v.end()) #define cout(n) cout << fixed << setprecision(n) #define rep(i, n) for (ll i = 0; i < n; i++) #define REP(i, n) for (ll i = 1; i < n; i++) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++) template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); } template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); } #define mod (ll)(1e9 + 7) #define INF LLONG_MAX signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a[i]; } map<ll, ll> m; rep(i, n) { m[a[i]]++; } FORm(it, m) { if (it->second > 1) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
43
49
43
50
TLE
p02779
C++
Runtime Error
/* Templatka c++ Kacper Fis // */ #include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <unordered_map> #include <utility> #include <vector> using namespace std; const int INF = 1000000001; const float PI = 3.14; typedef long long LL; typedef vector<int> vi; typedef list<int> li; typedef queue<int> qi; typedef pair<int, int> ii; typedef map<string, int> msi; // np msi['nazwa'] = 'liczba' typedef vector<ii> vii; // vector par<int>, do tworzenia tablicy dla grafów // wagowych #dijkstra #Bellman_Ford typedef priority_queue<ii, vector<ii>, greater<ii>> pq; // kolejka priorytetowa vectorów par(top()=min) #dijkstra vector<ii>::iterator iter; #define print_list(x) \ for (it = (x).begin(); it != (x).end(); it++) { \ cout << *it << " "; \ } #define print_vector(x) \ for (it2 = (x).begin(); it2 != (x).end(); it2++) { \ cout << *it2 << " "; \ } #define search_list(x) for (it = (x).begin(); it != (x).end(); it++) #define search_vector(x) \ for (it2 = (x).begin(); it2 != (x).end(); it2++) \ ; #define pb(x) push_back(x) #define pf(x) push_front(x) #define mp(x, y) make_pair(x, y) ///////////////////////////////////////////////GLOBAL ///DEFINITIONS//////////////////////////////////////////////////////// int tab[100005]; set<int> SET; ///////////////////////////////////////////////////FUNCTIONS///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////MAIN//////////////////////////////////////////////////////////////// int main(int argc, char *argv[]) { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool check = true; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> tab[i]; auto it = SET.find(tab[i]); if (it == SET.end()) { SET.insert(tab[i]); } else check = false; } if (check) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
/* Templatka c++ Kacper Fis // */ #include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <unordered_map> #include <utility> #include <vector> using namespace std; const int INF = 1000000001; const float PI = 3.14; typedef long long LL; typedef vector<int> vi; typedef list<int> li; typedef queue<int> qi; typedef pair<int, int> ii; typedef map<string, int> msi; // np msi['nazwa'] = 'liczba' typedef vector<ii> vii; // vector par<int>, do tworzenia tablicy dla grafów // wagowych #dijkstra #Bellman_Ford typedef priority_queue<ii, vector<ii>, greater<ii>> pq; // kolejka priorytetowa vectorów par(top()=min) #dijkstra vector<ii>::iterator iter; #define print_list(x) \ for (it = (x).begin(); it != (x).end(); it++) { \ cout << *it << " "; \ } #define print_vector(x) \ for (it2 = (x).begin(); it2 != (x).end(); it2++) { \ cout << *it2 << " "; \ } #define search_list(x) for (it = (x).begin(); it != (x).end(); it++) #define search_vector(x) \ for (it2 = (x).begin(); it2 != (x).end(); it2++) \ ; #define pb(x) push_back(x) #define pf(x) push_front(x) #define mp(x, y) make_pair(x, y) ///////////////////////////////////////////////GLOBAL ///DEFINITIONS//////////////////////////////////////////////////////// int tab[200005]; set<int> SET; ///////////////////////////////////////////////////FUNCTIONS///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////MAIN//////////////////////////////////////////////////////////////// int main(int argc, char *argv[]) { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool check = true; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> tab[i]; auto it = SET.find(tab[i]); if (it == SET.end()) { SET.insert(tab[i]); } else check = false; } if (check) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
replace
66
67
66
67
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long n; scanf("%lld", &n); long long arr[n]; for (long long i = 0; i < n; i++) scanf("%lld", &arr[i]); for (long long i = 0; i < n; i++) for (long long j = i + 1; j < n; j++) if (arr[i] == arr[j]) { cout << "NO\n"; return 0; } cout << "YES\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int arr[n]; for (int i = 0; i < n; i++) scanf("%d", &arr[i]); sort(arr, arr + n); for (int i = 0; i < n - 1; i++) if (arr[i] == arr[i + 1]) { cout << "NO\n"; return 0; } cout << "YES\n"; }
replace
4
15
4
15
TLE
p02779
C++
Runtime Error
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { long long int a = 0, b = 0, x = 0; long long int n = 0, ans = 0, count = 0; string s, t, u; vector<long long int> z; vector<long long int>::iterator position; bool q = false; cin >> n; for (int i = 0; i < s.size(); i++) { cin >> a; z.push_back(a); } sort(z.begin(), z.end()); for (int i = 0; i < n - 1; i++) { if (z.at(i) == z.at(i + 1)) { cout << "NO" << endl; break; } else if (i == n - 2) cout << "YES" << endl; } cout << endl; }
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { long long int a = 0, b = 0, x = 0; long long int n = 0, ans = 0, count = 0; string s, t, u; vector<long long int> z; vector<long long int>::iterator position; bool q = false; cin >> n; for (int i = 0; i < n; i++) { cin >> a; z.push_back(a); } sort(z.begin(), z.end()); for (int i = 0; i < n - 1; i++) { if (z.at(i) == z.at(i + 1)) { cout << "NO" << endl; break; } else if (i == n - 2) cout << "YES" << endl; } cout << endl; }
replace
13
14
13
14
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; long n, a[200000]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; for (int j = i - 1; j >= 0; --j) { if (a[i] == a[j]) { cout << "NO" << '\n'; return 0; } } } cout << "YES" << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; long n, a[200000]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a, a + n); for (int i = 1; i < n; ++i) { if (a[i] == a[i - 1]) { cout << "NO" << '\n'; return 0; } } cout << "YES" << '\n'; return 0; }
replace
7
12
7
13
TLE
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); } bool ans = false; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (A.at(i) == A.at(j)) { ans = true; break; } } if (ans) { break; } } if (ans) { cout << "NO" << endl; } else { cout << "YES" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); } bool ans = false; sort(A.begin(), A.end()); for (int i = 0; i < N - 1; i++) { if (A.at(i) == A.at(i + 1)) { ans = true; break; } } if (ans) { cout << "NO" << endl; } else { cout << "YES" << endl; } return 0; }
replace
10
18
10
14
TLE
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == j) continue; if (a.at(i) == a.at(j)) { cout << "NO" << endl; exit(0); } } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); for (int i = 0; i < N - 1; i++) { if (a.at(i) == a.at(i + 1)) { cout << "NO" << endl; exit(0); } } cout << "YES" << endl; }
replace
11
19
11
15
TLE
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; int S[200100]; cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; for (int j = 0; j < i; j++) { if (S[i] == S[j]) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; int S[200100]; cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; } sort(S, S + N); for (int i = 0; i < N - 1; i++) { if (S[i] == S[i + 1]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
9
14
9
15
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; bool a[2000000]; int main() { int N, b; cin >> N; for (int i = 0; i < N; i++) { cin >> b; if (a[b] == false) { a[b] = true; } else { cout << "NO"; return 0; } } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; bool a[2000000000]; int main() { int N, b; cin >> N; for (int i = 0; i < N; i++) { cin >> b; if (a[b] == false) { a[b] = true; } else { cout << "NO"; return 0; } } cout << "YES"; }
replace
2
3
2
3
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> arr(n); bool judge = true; for (int i = 0; i < n; i++) cin >> arr.at(i); for (int i = 0; i < n; i++) { for (int j = (i + 1); j < n; j++) { if (arr.at(i) == arr.at(j)) { judge = false; break; } } if (!judge) { break; } } if (judge) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> arr(n); bool judge = true; for (int i = 0; i < n; i++) cin >> arr.at(i); sort(arr.begin(), arr.end()); for (int i = 1; i < n; i++) { if (arr.at(i) == arr.at(i - 1)) { judge = false; break; } } if (judge) cout << "YES" << endl; else cout << "NO" << endl; }
replace
10
18
10
14
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int n; cin >> n; vector<int> arr(n); rep(i, n) { cin >> arr.at(i); } vector<bool> jud(200001); rep(i, n) { if (jud.at(arr.at(i))) { cout << "NO" << endl; return 0; } else { jud.at(arr.at(i)) = true; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int n; cin >> n; vector<int> arr(n); rep(i, n) { cin >> arr.at(i); } vector<bool> jud(1e9); rep(i, n) { if (jud.at(arr.at(i))) { cout << "NO" << endl; return 0; } else { jud.at(arr.at(i)) = true; } } cout << "YES" << endl; return 0; }
replace
9
10
9
10
0
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long bool vis[200006]; bool flag = 1; signed main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int b; cin >> b; if (vis[b]) flag = 0; vis[b] = 1; // if(a==b)flag = 0; // a = b; } if (flag) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long map<int, bool> vis; bool flag = 1; signed main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int b; cin >> b; if (vis[b]) flag = 0; vis[b] = 1; // if(a==b)flag = 0; // a = b; } if (flag) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
replace
4
5
4
5
0
p02779
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int using namespace std; ll ar[200007], a, b, test, sum, t, x = 0, p, q, y, i, j, k = 0, l, cnt; ll br[200007]; string s, s1, s2; int main() { ll test; cin >> a; for (i = 1; i <= a; i++) { cin >> ar[i]; br[ar[i]]++; } for (i = 1; i <= a; i++) if (br[ar[i]] > 1) { cout << "NO"; return 0; } cout << "YES" << endl; }
#include <bits/stdc++.h> #define ll long long int using namespace std; ll ar[200007], a, b, test, sum, t, x = 0, p, q, y, i, j, k = 0, l, cnt; map<ll, ll> br; string s, s1, s2; int main() { ll test; cin >> a; for (i = 1; i <= a; i++) { cin >> ar[i]; br[ar[i]]++; } for (i = 1; i <= a; i++) if (br[ar[i]] > 1) { cout << "NO"; return 0; } cout << "YES" << endl; }
replace
4
5
4
5
0
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; void printVector(vector<int> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << endl; } } int main() { int N; cin >> N; vector<int> vec; for (int i = 0; i < N; i++) { int A; cin >> A; vec.push_back(A); } for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (vec[i] == vec[j]) { cout << "NO" << endl; return EXIT_SUCCESS; } } } cout << "YES" << endl; return EXIT_SUCCESS; }
#include <algorithm> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; void printVector(vector<int> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << endl; } } int main() { int N; cin >> N; vector<int> vec; for (int i = 0; i < N; i++) { int A; cin >> A; vec.push_back(A); } sort(vec.begin(), vec.end()); for (int i = 0; i < N - 1; i++) { if (vec[i] == vec[i + 1]) { cout << "NO" << endl; return EXIT_SUCCESS; } } cout << "YES" << endl; return EXIT_SUCCESS; }
replace
22
28
22
27
TLE
p02779
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; long long mod = 1000000007; int main() { long long N; cin >> N; vector<long long> A; for (long long i; i < N; i++) { cin >> A[i]; } map<long, long> uss; for (long long i; i < N; i++) { uss[(A[i])]++; } for (long long i; i < N; i++) { if (uss[(A[i])] >= 2) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
#include <algorithm> #include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; long long mod = 1000000007; int main() { long long N; cin >> N; vector<long long> A(N); for (long long i; i < N; i++) { cin >> A[i]; } map<long, long> uss; for (long long i; i < N; i++) { uss[(A[i])]++; } for (long long i; i < N; i++) { if (uss[(A[i])] >= 2) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
replace
16
17
16
17
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n = 0; cin >> n; vector<long long int> a(n, 0); for (int i = 0; i < n; i++) { cin >> a[i]; for (int k = 0; k < i; k++) { if (a[k] == a[i]) { cout << "NO\n"; return 0; } } } cout << "YES\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n = 0; cin >> n; vector<long long int> a(n, 0); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); for (int i = 0; i < n - 1; i++) { if (a[i] == a[i + 1]) { cout << "NO\n"; return 0; } } cout << "YES\n"; return 0; }
replace
10
15
10
18
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int N; cin >> N; vector<int> A(N); vector<bool> B(200050, true); bool ans = true; rep(i, N) { cin >> A.at(i); if (B.at(A.at(i))) { B.at(A.at(i)) = false; } else { ans = false; } } cout << (ans ? "YES" : "NO") << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int N; cin >> N; vector<int> A(N); vector<bool> B(1000000050, true); bool ans = true; rep(i, N) { cin >> A.at(i); if (B.at(A.at(i))) { B.at(A.at(i)) = false; } else { ans = false; } } cout << (ans ? "YES" : "NO") << endl; }
replace
9
10
9
10
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec(n); for (int i = 0; i < n; i++) { cin >> vec.at(i); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j && vec.at(i) == vec.at(j)) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec(n); for (int i = 0; i < n; i++) { cin >> vec.at(i); } sort(vec.begin(), vec.end()); for (int i = 0; i < n - 1; i++) { if (vec.at(i) == vec.at(i + 1)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
replace
10
16
10
15
TLE
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, C = 1; cin >> N; vector<long> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (A.at(i) == A.at(j)) C = 0; } } if (C == 1) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, C = 1; cin >> N; vector<long> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); sort(A.begin(), A.end()); for (int i = 0; i < N - 1; i++) { if (A.at(i) == A.at(i + 1)) C = 0; } if (C == 1) cout << "YES" << endl; else cout << "NO" << endl; }
replace
9
14
9
14
TLE
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); } int ex = 0; for (int i = 0; i < N - 1; i++) { for (int j = i + 1; j < N; j++) { if (A.at(i) == A.at(j)) { ex++; break; } } } if (ex > 0) { cout << "NO" << endl; } else { cout << "YES" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); } sort(A.begin(), A.end()); A.erase(unique(A.begin(), A.end()), A.end()); if (A.size() < N) { cout << "NO" << endl; } else { cout << "YES" << endl; } }
replace
10
20
10
13
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 int LMS(int n, int k) { if (n == 1) return 1; else /* The position returned by josephus(n - 1, k) is adjusted because the recursive call josephus(n - 1, k) considers the original position k%n + 1 as position 1 */ return (LMS(n - 1, k) + k - 1) % n + 1; } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t--) { int n; cin >> n; set<int> s; int a; for (int i = 0; i < n; ++i) { cin >> a; s.insert(a); } if (s.size() == n) cout << "YES"; else cout << "NO"; } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 int LMS(int n, int k) { if (n == 1) return 1; else /* The position returned by josephus(n - 1, k) is adjusted because the recursive call josephus(n - 1, k) considers the original position k%n + 1 as position 1 */ return (LMS(n - 1, k) + k - 1) % n + 1; } int main() { int t = 1; // cin >> t; while (t--) { int n; cin >> n; set<int> s; int a; for (int i = 0; i < n; ++i) { cin >> a; s.insert(a); } if (s.size() == n) cout << "YES"; else cout << "NO"; } return 0; }
delete
14
21
14
14
0
p02779
C++
Memory Limit Exceeded
// clang-format off #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i) #define rrep(i,n) for(ll i=n-1; i>=0; --i) #define rrep1(i,n) for(ll i=n; i>0; --i) #define all(x) (x).begin(),(x).end() #define SORT(x) sort(all(x)) #define SORT_DESC(x) sort(all(x), greater<>()) #define pb push_back #define mp make_pair #define coutl cout<<fixed<<setprecision(10) #define ANS(ans) cout<<ans<<endl; const ll LINF = (1LL << 62) - 1; const int INF = (1 << 30) - 1; template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;} const string YES = "YES"; const string NO = "NO"; // clang-format on void solve(long long N, std::vector<long long> A) { vector<bool> a(1e10); rep(i, N) { if (a[A[i]]) { ANS(NO); return; } a[A[i]] = true; } ANS(YES); } // clang-format off int main() { long long N; scanf("%lld",&N); std::vector<long long> A(N); for(int i = 0 ; i < N ; i++){ scanf("%lld",&A[i]); } solve(N, std::move(A)); return 0; }
// clang-format off #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i) #define rrep(i,n) for(ll i=n-1; i>=0; --i) #define rrep1(i,n) for(ll i=n; i>0; --i) #define all(x) (x).begin(),(x).end() #define SORT(x) sort(all(x)) #define SORT_DESC(x) sort(all(x), greater<>()) #define pb push_back #define mp make_pair #define coutl cout<<fixed<<setprecision(10) #define ANS(ans) cout<<ans<<endl; const ll LINF = (1LL << 62) - 1; const int INF = (1 << 30) - 1; template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;} const string YES = "YES"; const string NO = "NO"; // clang-format on void solve(long long N, std::vector<long long> A) { vector<bool> a(INF); rep(i, N) { if (a[A[i]]) { ANS(NO); return; } a[A[i]] = true; } ANS(YES); } // clang-format off int main() { long long N; scanf("%lld",&N); std::vector<long long> A(N); for(int i = 0 ; i < N ; i++){ scanf("%lld",&A[i]); } solve(N, std::move(A)); return 0; }
replace
26
27
26
27
MLE
p02779
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { int n, i, j; int a[100005], flag = 0; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 1; i < n; i++) { if (a[i] == a[i - 1]) { flag = 1; break; } } if (flag) cout << "NO"; else cout << "YES"; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { int n, i, j; long long a[200005], flag = 0; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 1; i < n; i++) { if (a[i] == a[i - 1]) { flag = 1; break; } } if (flag) cout << "NO"; else cout << "YES"; }
replace
7
8
7
8
0
p02779
Python
Time Limit Exceeded
def main(): n = int(input()) A = list(map(int, input().split())) for i in range(n): a = A.pop() if a in A: print("NO") return print("YES") if __name__ == "__main__": main()
def main(): n = int(input()) A = list(map(int, input().split())) A_set = set(A) if len(A) == len(A_set): print("YES") else: print("NO") if __name__ == "__main__": main()
replace
4
10
4
9
TLE
p02779
Python
Time Limit Exceeded
n = int(input()) a = input().split() flag = False for i in range(n): for j in range(i + 1, n): if a[i] == a[j]: flag = True break if flag: break if flag: print("NO") else: print("YES")
n = int(input()) a = [int(i) for i in input().split()] if len(a) != len(set(a)): print("NO") else: print("YES")
replace
1
12
1
3
TLE
p02779
Python
Time Limit Exceeded
n = int(input()) a = list(map(int, input().split())) for i in a: if a.count(i) >= 2: print("NO") exit() print("YES")
n = int(input()) a = list(map(int, input().split())) b = set(a) a.sort() if len(a) != len(b): print("NO") else: print("YES")
replace
2
7
2
8
TLE
p02779
Python
Time Limit Exceeded
n = int(input()) num_list = list(map(int, input().split())) out = "YES" for j in range(len(num_list)): for k in num_list[j + 1 :]: out = "NO" if num_list[j] == k else out print(out)
n = int(input()) num_list = list(map(int, input().split())) out = "YES" if len(num_list) == len(set(num_list)) else "NO" print(out)
replace
2
6
2
3
TLE
p02779
Python
Time Limit Exceeded
N = int(input()) A = list(map(int, input().split())) answer = "YES" for i in range(N): c = A.count(A[i]) if c >= 2: answer = "NO" break print(answer)
N = int(input()) A = list(map(int, input().split())) answer = "YES" AA = sorted(A) for i in range(N - 1): if AA[i] == AA[i + 1]: answer = "NO" break print(answer)
replace
4
7
4
7
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; bool a = true; vector<int> wtf(N); for (int i = 0; i < N; i++) { cin >> wtf.at(i); } sort(wtf.begin(), wtf.end()); for (int i = 0; i < N; i++) { if (wtf.at(i) == wtf.at(i + 1)) { a = false; break; } } if (a == true) { cout << "YES" << endl; } else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; bool a = true; vector<int> wtf(N); for (int i = 0; i < N; i++) { cin >> wtf.at(i); } sort(wtf.begin(), wtf.end()); for (int i = 0; i < N - 1; i++) { if (wtf.at(i) == wtf.at(i + 1)) { a = false; break; } } if (a == true) { cout << "YES" << endl; } else cout << "NO" << endl; }
replace
11
12
11
12
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <utility> #include <vector> #define rep(i, s, g) for (i = s; i <= g; i++) using namespace std; using ll = long long; using P = pair<int, int>; const ll MOD = 1e9 + 7; int main(void) { int N; vector<int> A; int i, j; cin >> N; A.resize(N); rep(i, 0, N - 1) { cin >> A[i]; rep(j, 0, i - 1) { if (A[i] == A[j]) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <utility> #include <vector> #define rep(i, s, g) for (i = s; i <= g; i++) using namespace std; using ll = long long; using P = pair<int, int>; const ll MOD = 1e9 + 7; int main(void) { int N; vector<int> A; int i, j; cin >> N; A.resize(N); rep(i, 0, N - 1) { cin >> A[i]; } sort(A.begin(), A.end()); rep(i, 1, N - 1) { if (A[i] == A[i - 1]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
replace
23
30
23
31
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long ll; #define _GLIBCXX_DEBUG int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> d(1000000000); rep(i, n) { d[a[i]]++; } rep(i, n) { if (d[i] >= 2) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long ll; #define _GLIBCXX_DEBUG int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(a.begin(), a.end()); rep(i, n - 1) { if (a[i] == a[i + 1]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
replace
12
16
12
15
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a.at(i); } rep(i, n) { for (int j = i + 1; j < n; j++) { if (a.at(i) == a.at(j)) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a.at(i); } sort(a.begin(), a.end()); rep(i, n - 1) { if (a.at(i) == a.at(i + 1)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
9
15
9
14
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> #define f(i, n) for (int i = 0; i < (n); i++) #define inf (int)(3e18) #define int long long #define mod (int)(1000000007) #define intt long long using namespace std; // Library // モッドパウ int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y % 2) { res *= x; res %= m; } x = x * x % mod; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } // saidai-kouyakusuu int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // Union-Find Tree class Union_Find { vector<int> par; vector<int> rankmy; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; } else { par[y] = x; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } bool same(int x, int y) { return find(x) == find(y); } }; // Union-Find-End // SegTree template <class T> class SegTree { int n; // 葉の数 vector<T> data; // データを格納するvector T def; // 初期値かつ単位元 function<T(T, T)> operation; // 区間クエリで使う処理 function<T(T, T)> update; // 点更新で使う処理 // 区間[a,b)の総和。ノードk=[l,r)に着目している。 T _query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; // 交差しない if (a <= l && r <= b) return data[k]; // a,l,r,bの順で完全に含まれる else { T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return operation(c1, c2); } } public: // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // _update:更新関数 SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } data = vector<T>(2 * n - 1, def); } // 場所i(0-indexed)の値をxで更新 void change(int i, T x) { i += n - 1; data[i] = update(data[i], x); while (i > 0) { i = (i - 1) / 2; data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]); } } // [a, b)の区間クエリを実行 T query(int a, int b) { return _query(a, b, 0, 0, n); } // 添字でアクセス T operator[](int i) { return data[i + n - 1]; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } // Seg-Tree-End // dfs // vector<int> v[100004]; // bool went[100004]; // void dfs(int x) { // went[x] = true; // for (int i = 0; i < (int)v[x].size(); i++) { // if (!went[v[x][i]]) { // dfs(v[x][i]); // } // } // } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x /= 2; } else { break; } } return ans; } int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } int fukugen(vector<int> l) { int ans = 0; for (int i = 0; i < (int)l.size(); i++) { ans *= 10; ans += l[i]; } return ans; } #define rep(i, n) for (int i = 0; i < n; i++) // Library-End int n, ans, a[100004]; map<int, bool> mp; signed main() { cin >> n; rep(i, n) { cin >> a[i]; if (mp[a[i]]) { cout << "NO" << endl; return 0; } mp[a[i]] = 1; } cout << "YES" << endl; }
#include <bits/stdc++.h> #define f(i, n) for (int i = 0; i < (n); i++) #define inf (int)(3e18) #define int long long #define mod (int)(1000000007) #define intt long long using namespace std; // Library // モッドパウ int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y % 2) { res *= x; res %= m; } x = x * x % mod; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } // saidai-kouyakusuu int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // Union-Find Tree class Union_Find { vector<int> par; vector<int> rankmy; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; } else { par[y] = x; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } bool same(int x, int y) { return find(x) == find(y); } }; // Union-Find-End // SegTree template <class T> class SegTree { int n; // 葉の数 vector<T> data; // データを格納するvector T def; // 初期値かつ単位元 function<T(T, T)> operation; // 区間クエリで使う処理 function<T(T, T)> update; // 点更新で使う処理 // 区間[a,b)の総和。ノードk=[l,r)に着目している。 T _query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; // 交差しない if (a <= l && r <= b) return data[k]; // a,l,r,bの順で完全に含まれる else { T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return operation(c1, c2); } } public: // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // _update:更新関数 SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } data = vector<T>(2 * n - 1, def); } // 場所i(0-indexed)の値をxで更新 void change(int i, T x) { i += n - 1; data[i] = update(data[i], x); while (i > 0) { i = (i - 1) / 2; data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]); } } // [a, b)の区間クエリを実行 T query(int a, int b) { return _query(a, b, 0, 0, n); } // 添字でアクセス T operator[](int i) { return data[i + n - 1]; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } // Seg-Tree-End // dfs // vector<int> v[100004]; // bool went[100004]; // void dfs(int x) { // went[x] = true; // for (int i = 0; i < (int)v[x].size(); i++) { // if (!went[v[x][i]]) { // dfs(v[x][i]); // } // } // } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x /= 2; } else { break; } } return ans; } int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } int fukugen(vector<int> l) { int ans = 0; for (int i = 0; i < (int)l.size(); i++) { ans *= 10; ans += l[i]; } return ans; } #define rep(i, n) for (int i = 0; i < n; i++) // Library-End int n, ans, a[200004]; map<int, bool> mp; signed main() { cin >> n; rep(i, n) { cin >> a[i]; if (mp[a[i]]) { cout << "NO" << endl; return 0; } mp[a[i]] = 1; } cout << "YES" << endl; }
replace
242
243
242
243
0
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int A[200000] = {0}; int N; int main(void) { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } std::sort(A, A + N); for (int i = 0; i < N - 1; i++) { for (int j = i + 1; j < N; j++) { if (A[i] == A[j]) { cout << "NO"; return 0; } } } cout << "YES"; return 0; }
#include <algorithm> #include <iostream> using namespace std; int A[200000] = {0}; int N; int main(void) { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } std::sort(A, A + N); for (int i = 0; i < N - 1; i++) { if (A[i] == A[i + 1]) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
replace
15
20
15
18
TLE
p02779
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(obj) (obj).begin(), (obj).end() using namespace std; typedef long long ll; const int INF = 1001001001; int main() { int N; cin >> N; vector<int> cnt(N); for (int i = 1; i <= N; ++i) cin >> cnt[i]; cnt[0] = 0; sort(all(cnt)); for (int j = 1; j <= N; ++j) { if (cnt[j - 1] == cnt[j]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define all(obj) (obj).begin(), (obj).end() using namespace std; typedef long long ll; const int INF = 1001001001; int main() { int N; cin >> N; vector<int> cnt(N + 1); for (int i = 1; i <= N; ++i) cin >> cnt[i]; cnt[0] = 0; sort(all(cnt)); for (int j = 1; j <= N; ++j) { if (cnt[j - 1] == cnt[j]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
11
12
11
12
0
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int n, a[100004]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) { cout << "NO"; return 0; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; int n, a[200004]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) { cout << "NO"; return 0; } cout << "YES"; }
replace
2
3
2
3
0
p02779
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; int main() { int N; cin >> N; vector<string> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { if (A[i] == A[j]) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }
#include "bits/stdc++.h" using namespace std; int main() { int N; cin >> N; vector<string> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } sort(A.begin(), A.end()); for (int i = 0; i < N - 1; ++i) { if (A[i] == A[i + 1]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
10
16
10
15
TLE
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <string> #include <vector> using namespace std; const int mod = 1000000007; #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) #define ll long long int findIndex(vector<long> vec, long value) { vector<long>::iterator iter = std::find(vec.begin(), vec.end(), value); size_t index = distance(vec.begin(), iter); if (index == vec.size()) { return -1; } return index; } int main() { long n; cin >> n; vector<long> vec(n); for (long i = 0; i < n; i++) { long a; cin >> a; vec[i] = a; } for (long i = 0; i < n; i++) { long b = vec[i]; for (long j = i + 1; j < n; j++) { if (b == vec[j]) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <string> #include <vector> using namespace std; const int mod = 1000000007; #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) #define ll long long int findIndex(vector<long> vec, long value) { vector<long>::iterator iter = std::find(vec.begin(), vec.end(), value); size_t index = distance(vec.begin(), iter); if (index == vec.size()) { return -1; } return index; } int main() { long n; cin >> n; vector<long> vec(n); for (long i = 0; i < n; i++) { long a; cin >> a; vec[i] = a; } sort(vec.begin(), vec.end(), greater<int>()); // 降順 for (long i = 0; i < n - 1; i++) { if (vec[i] == vec[i + 1]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
35
42
35
41
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; string s, t; int n; int judge = 1; string u; vector<int> a(200000); int main(int argc, char const *argv[]) { cin >> n; for (int i = 0; i < n; ++i) { cin >> a.at(i); } sort(a.begin(), a.end(), greater<int>()); // for(int i = 0; i<n;i++) cout << a.at(i) << endl; for (int i = 0; i < n; ++i) { if (a.at(i) == a.at(i + 1)) { judge = 0; break; } } if (judge == 1) cout << "YES" << endl; if (judge == 0) cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string s, t; int n; int judge = 1; string u; vector<int> a(200010); int main(int argc, char const *argv[]) { cin >> n; for (int i = 0; i < n; ++i) { cin >> a.at(i); } sort(a.begin(), a.end(), greater<int>()); // for(int i = 0; i<n;i++) cout << a.at(i) << endl; for (int i = 0; i < n; ++i) { if (a.at(i) == a.at(i + 1)) { judge = 0; break; } } if (judge == 1) cout << "YES" << endl; if (judge == 0) cout << "NO" << endl; return 0; }
replace
7
8
7
8
0
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] == a[j]) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; }
#include <algorithm> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); for (int i = 0; i < n; i++) { if (a[i] == a[i + 1]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
replace
19
24
19
22
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define ll long long #define ii pair<int, int> #define vi vector<int> #define vll vector<ll> #define vii vector<ii> using namespace std; void solve() { return; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, aux; map<int, int> ma; bool t = true; cin >> n; for (int i = 0; i < n; i++) { cin >> aux; if (ma[aux] != 0) t = false; ma[aux]++; } cout << (t ? "YES" : "NO") << endl; return 0; }
#include <bits/stdc++.h> #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define ll long long #define ii pair<int, int> #define vi vector<int> #define vll vector<ll> #define vii vector<ii> using namespace std; void solve() { return; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, aux; map<int, int> ma; bool t = true; cin >> n; for (int i = 0; i < n; i++) { cin >> aux; if (ma[aux] != 0) t = false; ma[aux]++; } cout << (t ? "YES" : "NO") << endl; return 0; }
delete
20
24
20
20
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define urng(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define urep(i, b) urng(i, 0, b) #define pb push_back #define eb emplace_back #define F first #define S second #define bg begin() #define ed end() #define all(x) x.bg, x.ed int main() { int n, b, ans = 0; // string s; cin >> n; vector<int> a(n); // if(1) {} //((a == b)? "Yes" : "No") rep(i, n) cin >> a.at(i); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a.at(i) == a.at(j)) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define urng(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define urep(i, b) urng(i, 0, b) #define pb push_back #define eb emplace_back #define F first #define S second #define bg begin() #define ed end() #define all(x) x.bg, x.ed int main() { int n, b, ans = 0; // string s; cin >> n; vector<int> a(n); // if(1) {} //((a == b)? "Yes" : "No") rep(i, n) cin >> a.at(i); sort(all(a)); for (int i = 1; i < n; i++) { if (a.at(i) == a.at(i - 1)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
replace
24
30
24
29
TLE
p02779
C++
Runtime Error
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { long long int n, c = 0; cin >> n; vector<long long int> a(100000); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end(), std::greater<>()); for (int i = 0; i < n - 1; i++) { if (a[i] == a[i + 1]) { c = 1; } } if (c == 1) { cout << "NO" << endl; } else { cout << "YES" << endl; } return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { long long int n, c = 0; cin >> n; vector<long long int> a(1000000); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end(), std::greater<>()); for (int i = 0; i < n - 1; i++) { if (a[i] == a[i + 1]) { c = 1; } } if (c == 1) { cout << "NO" << endl; } else { cout << "YES" << endl; } return 0; }
replace
9
10
9
10
0
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; long long int n, arr[10 ^ 9]; int main() { int flag; flag = 1; long long int i; scanf("%lld", &n); for (i = 0; i < n; i++) { scanf("%lld", &arr[i]); } sort(arr, arr + n); for (i = 0; i < n; i++) { if (arr[i] == arr[i + 1]) { flag = 0; printf("NO"); break; } // scanf("%lld",&arr[i]); } if (flag == 1) { printf("YES"); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; long long int n, arr[100000000]; int main() { int flag; flag = 1; long long int i; scanf("%lld", &n); for (i = 0; i < n; i++) { scanf("%lld", &arr[i]); } sort(arr, arr + n); for (i = 0; i < n; i++) { if (arr[i] == arr[i + 1]) { flag = 0; printf("NO"); break; } // scanf("%lld",&arr[i]); } if (flag == 1) { printf("YES"); } printf("\n"); return 0; }
replace
2
3
2
3
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } for (int i = 0; i < n; i++) { if (count(a.begin() + i, a.end(), a.at(i)) != 1) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
11
13
11
14
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 7; int a[N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; bool bl = true; for (int i = 0; i < n; ++i) { int x; cin >> x; ++a[x]; if (a[x] > 1) bl = false; } bl ? cout << "YES\n" : cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 7; unordered_map<int, int> a; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; bool bl = true; for (int i = 0; i < n; ++i) { int x; cin >> x; ++a[x]; if (a[x] > 1) bl = false; } bl ? cout << "YES\n" : cout << "NO\n"; return 0; }
replace
4
5
4
5
0
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = a; i <= b; i++) #define FORd(i, a, b) for (int i = a; i >= b; i--) #define fi first #define se second #define II pair<ll, ll> const int maxn = 2e5 + 10; const ll maxN = 1e18 + 10; ll ST[maxn], a[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int> dd(maxn, 0); FOR(i, 1, n) { int h; cin >> h; if (dd[h] == 1) { cout << "NO"; exit(0); } dd[h] = 1; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, b) for (int i = a; i <= b; i++) #define FORd(i, a, b) for (int i = a; i >= b; i--) #define fi first #define se second #define II pair<ll, ll> const int maxn = 2e5 + 10; const ll maxN = 1e18 + 10; ll ST[maxn], a[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; map<ll, ll> dd; FOR(i, 1, n) { int h; cin >> h; if (dd[h] == 1) { cout << "NO"; exit(0); } dd[h] = 1; } cout << "YES"; }
replace
23
24
23
24
0
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> #define ll long long using namespace std; struct dog { string a; int b; }; int main() { // dog shiba; dog pa; // cin >> shiba.a >> pa.a; // cin >> shiba.b >> pa.b; // string key; // cin >> key; // if (shiba.a == key)shiba.b -= 1; // else if (pa.a == key)pa.b -= 1; // cout << shiba.b << " " << pa.b; // string key; // cin >> key; // for (int i = 0; i < key.length(); i++) //{ // cout << "x"; // } int n; cin >> n; vector<ll> dog; for (int i = 0; i < n; i++) { ll a; cin >> a; dog.push_back(a); } sort(dog.begin(), dog.end()); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (dog[i] == dog[j]) { cout << "NO"; exit(0); } } } cout << "YES"; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> #define ll long long using namespace std; struct dog { string a; int b; }; int main() { // dog shiba; dog pa; // cin >> shiba.a >> pa.a; // cin >> shiba.b >> pa.b; // string key; // cin >> key; // if (shiba.a == key)shiba.b -= 1; // else if (pa.a == key)pa.b -= 1; // cout << shiba.b << " " << pa.b; // string key; // cin >> key; // for (int i = 0; i < key.length(); i++) //{ // cout << "x"; // } int n; cin >> n; vector<ll> dog; for (int i = 0; i < n; i++) { ll a; cin >> a; dog.push_back(a); } sort(dog.begin(), dog.end()); for (int i = 0; i + 1 < n; i++) { if (dog[i] == dog[i + 1]) { cout << "NO"; exit(0); } } cout << "YES"; }
replace
37
43
37
41
TLE
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long typedef pair<ll, ll> pii; const int maxn = 2e5 + 10; const int INF = 0x3f3f3f3f; const ll inf = 1e18; const ll mod = 1000000007; int vis[maxn], n; bool flg = 1; int main() { cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; if (vis[x]) flg = 0; vis[x] = 1; } puts(flg ? "YES" : "NO"); return 0; };
#include <bits/stdc++.h> using namespace std; #define ll long long typedef pair<ll, ll> pii; const int maxn = 2e5 + 10; const int INF = 0x3f3f3f3f; const ll inf = 1e18; const ll mod = 1000000007; int n; map<int, int> vis; bool flg = 1; int main() { cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; if (vis[x]) flg = 0; vis[x] = 1; } puts(flg ? "YES" : "NO"); return 0; };
replace
8
9
8
10
0
p02779
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; long long z[2323]; int n, m; int main() { bool flag = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> m; z[i] = m; } sort(z, z + n); for (int i = 0; i < n - 1; i++) { if (z[i] == z[i + 1]) flag = 1; } if (flag == 1) cout << "NO"; else cout << "YES"; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; long long z[0x3f3f3f]; int n, m; int main() { bool flag = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> m; z[i] = m; } sort(z, z + n); for (int i = 0; i < n - 1; i++) { if (z[i] == z[i + 1]) flag = 1; } if (flag == 1) cout << "NO"; else cout << "YES"; return 0; }
replace
6
7
6
7
0
p02779
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); int l, ii = 0; while (cin >> l) { A[ii] = l; ii++; } sort(A.begin(), A.end()); string answer = "YES"; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { if (A[i] == A[j]) { answer = "NO"; break; } } } cout << answer << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); int l, ii = 0; while (cin >> l) { A[ii] = l; ii++; } sort(A.begin(), A.end()); string answer = "YES"; for (int i = 0; i < N - 1; i++) { if (A[i] == A[i + 1]) { answer = "NO"; break; } } cout << answer << endl; return 0; }
replace
20
26
20
24
TLE
p02779
C++
Runtime Error
#include <iostream> #include <set> #include <vector> using namespace std; int main() { int N; cin >> N; vector<double> A; set<double> A_set; for (int i = 0; i < N; i++) { cin >> A.at(i); A_set.insert(A.at(i)); } if (A.size() == A_set.size()) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <iostream> #include <set> #include <vector> using namespace std; int main() { int N; cin >> N; vector<double> A(N); set<double> A_set; for (int i = 0; i < N; i++) { cin >> A.at(i); A_set.insert(A.at(i)); } if (A.size() == A_set.size()) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
replace
10
11
10
11
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
p02779
C++
Runtime Error
#include <bits/stdc++.h> #include <random> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int N; cin >> N; vector<int> v{istream_iterator<int>(cin), istream_iterator<int>()}; std::sort(v.begin(), v.end() - 1); rep(i, int(v.size())) { if (int(v.at(i)) == v.at(i + 1)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> #include <random> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int N; cin >> N; vector<int> v{istream_iterator<int>(cin), istream_iterator<int>()}; std::sort(v.begin(), v.end()); rep(i, int(v.size()) - 1) { if (int(v.at(i)) == v.at(i + 1)) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
replace
10
12
10
12
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<bool> arr(1e7); bool dis = 1; for (int i = 0; i < n; i++) { int t; cin >> t; if (arr[t]) { dis = 0; } arr[t] = 1; } if (dis) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> arr; bool dis = 1; for (int i = 0; i < n; i++) { int t; cin >> t; if (arr[t]) { dis = 0; } arr[t] = 1; } if (dis) cout << "YES"; else cout << "NO"; }
replace
6
7
6
7
0
p02779
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, s = 0, a[100000]; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] != a[i + 1]) { s++; } } if (s == n) { cout << "YES" << endl; ; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, s = 0, a[200110]; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] != a[i + 1]) { s++; } } if (s == n) { cout << "YES" << endl; ; } else { cout << "NO" << endl; } return 0; }
replace
3
4
3
4
0
p02779
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; vector<int> a(N); rep(i, N) { cin >> a[i]; } rep(i, N) { rep(j, N) { if (a[i] == a[j] && i != j) { cout << "NO" << endl; return 0; } else { continue; } } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; vector<int> a(N); rep(i, N) { cin >> a[i]; } sort(a.begin(), a.end()); rep(i, N - 1) { if (a[i] == a[i + 1]) { cout << "NO" << endl; return 0; } else { continue; } } cout << "YES" << endl; }
replace
9
17
9
16
TLE
p02779
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define MOD 1000000007 int main() { ll n; vector<bool> as = {}; cin >> n; as.resize(100000001, false); for (auto i = 0; i < n; i++) { ll a; cin >> a; if (as[a]) { cout << "NO" << endl; return 0; } else { as[a] = true; } } cout << "YES" << endl; return 0; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define MOD 1000000007 int main() { ll n; vector<bool> as = {}; cin >> n; as.resize(1000000001, false); for (auto i = 0; i < n; i++) { ll a; cin >> a; if (as[a]) { cout << "NO" << endl; return 0; } else { as[a] = true; } } cout << "YES" << endl; return 0; }
replace
11
12
11
12
0
p02780
C++
Runtime Error
#include <bits/stdc++.h> #define repeat(i, n) for (ll(i) = 0; (i) < (n); (i)++) using namespace std; typedef long long ll; int main() { int N, K; cin >> N >> K; vector<int> p(N, 0); vector<double> expect(N, 0.0), list(N, 0.0); double result = 0.0; repeat(i, N) { cin >> p[i]; expect[i] = (double)(1 + p[i]) / 2.0; } list[0] = 0; for (int i = 1; i <= N; i++) { list[i] = list[i - 1] + expect[i - 1]; } for (int i = K; i <= N; i++) { result = max(result, list[i] - list[i - K]); }; cout << fixed << setprecision(10) << result << endl; return 0; }
#include <bits/stdc++.h> #define repeat(i, n) for (ll(i) = 0; (i) < (n); (i)++) using namespace std; typedef long long ll; int main() { int N, K; cin >> N >> K; vector<int> p(N, 0); vector<double> expect(210000, 0.0), list(210000, 0.0); double result = 0.0; repeat(i, N) { cin >> p[i]; expect[i] = (double)(1 + p[i]) / 2.0; } list[0] = 0; for (int i = 1; i <= N; i++) { list[i] = list[i - 1] + expect[i - 1]; } for (int i = K; i <= N; i++) { result = max(result, list[i] - list[i - K]); }; cout << fixed << setprecision(10) << result << endl; return 0; }
replace
9
10
9
10
-6
malloc(): corrupted top size
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<double> p(N); for (int i = 0; i < N; ++i) cin >> p[i]; vector<double> sum(N + 1); sum[0] = 0; for (int i = 0; i < N; ++i) { double e = (p[i] * (p[i] + 1)) / 2; e /= p[i]; sum[i + 1] = sum[i] + e; } double ans = -1.; for (int i = 0; i < N - 2; ++i) { ans = max(ans, sum[i + K] - sum[i]); } printf("%.10lf\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<double> p(N); for (int i = 0; i < N; ++i) cin >> p[i]; vector<double> sum(N + 1); sum[0] = 0; for (int i = 0; i < N; ++i) { double e = (p[i] * (p[i] + 1)) / 2; e /= p[i]; sum[i + 1] = sum[i] + e; } double ans = -1.; for (int i = 0; i < N - K + 1; ++i) { ans = max(ans, sum[i + K] - sum[i]); } printf("%.10lf\n", ans); return 0; }
replace
19
20
19
20
0
p02780
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ll long long using namespace std; /*階乗*/ ll factorial(ll n) { if (n == 0) { return 1; } else { return n * factorial(n - 1) % 1000000007; } } /* ユークリッドの互除法 最大公約数*/ /*ll gcd(ll a, ll b) { ll r; r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } */ /*最小公倍数*/ /* ll lcm(ll a,ll b){ return a/gcd(a,b)*b; } */ /*二点間の距離*/ double dist(pair<double, double> a, pair<double, double> b) { return sqrt(pow((a.first - b.first), 2) + pow((a.second - b.second), 2)); } // 繰り返し自乗法 double ism(double aa, ll p) { double ap = aa; double ans = 1; while (p > 0) { // cout<<"p="<<p<<",ap="<<ap<<endl; if (p & 1) { // 奇数が真 ans *= ap; } p /= 2; ap = ap * ap; } return ans; } // 繰り返し自乗法(アマリトリバージョン) ll ismm(ll aa, ll p, ll m) { ll ap = aa; ll ans = 1; while (p > 0) { // cout<<"p="<<p<<",ap="<<ap<<endl; if (p & 1) { // 奇数が真 ans = (ans * ap) % m; } p /= 2; ap = (ap * ap) % m; } return ans; } /* ll solve(ll i,ll m,vector<ll>t,ll n){ if(m==0){ return 1; } if(i>=n){ return 0; } cout<<i+1<<" "<<m<<endl; cout<<i+1<<" "<<m-t[i]<<endl; ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n); return res; } */ // 小数点12桁 struct all_init { all_init() { cout << fixed << setprecision(12); } } All_init; int main() { ll n, k; cin >> n >> k; vector<ll> p(n); vector<double> sum(n + 1, 0); for (ll i = 0; i < n; i++) { cin >> p[i]; } double a = 0; for (ll i = 0; i < n + 1; i++) { a += (1 + p[i]) / 2.0; sum[i + 1] = a; } double ans = 0; for (ll i = 0; i < n + 1 - k; i++) { ans = max(sum[i + k] - sum[i], ans); } cout << ans << endl; }
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ll long long using namespace std; /*階乗*/ ll factorial(ll n) { if (n == 0) { return 1; } else { return n * factorial(n - 1) % 1000000007; } } /* ユークリッドの互除法 最大公約数*/ /*ll gcd(ll a, ll b) { ll r; r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } */ /*最小公倍数*/ /* ll lcm(ll a,ll b){ return a/gcd(a,b)*b; } */ /*二点間の距離*/ double dist(pair<double, double> a, pair<double, double> b) { return sqrt(pow((a.first - b.first), 2) + pow((a.second - b.second), 2)); } // 繰り返し自乗法 double ism(double aa, ll p) { double ap = aa; double ans = 1; while (p > 0) { // cout<<"p="<<p<<",ap="<<ap<<endl; if (p & 1) { // 奇数が真 ans *= ap; } p /= 2; ap = ap * ap; } return ans; } // 繰り返し自乗法(アマリトリバージョン) ll ismm(ll aa, ll p, ll m) { ll ap = aa; ll ans = 1; while (p > 0) { // cout<<"p="<<p<<",ap="<<ap<<endl; if (p & 1) { // 奇数が真 ans = (ans * ap) % m; } p /= 2; ap = (ap * ap) % m; } return ans; } /* ll solve(ll i,ll m,vector<ll>t,ll n){ if(m==0){ return 1; } if(i>=n){ return 0; } cout<<i+1<<" "<<m<<endl; cout<<i+1<<" "<<m-t[i]<<endl; ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n); return res; } */ // 小数点12桁 struct all_init { all_init() { cout << fixed << setprecision(12); } } All_init; int main() { ll n, k; cin >> n >> k; vector<ll> p(n); vector<double> sum(n + 1, 0); for (ll i = 0; i < n; i++) { cin >> p[i]; } double a = 0; for (ll i = 0; i < n; i++) { a += (1 + p[i]) / 2.0; sum[i + 1] = a; } double ans = 0; for (ll i = 0; i < n + 1 - k; i++) { ans = max(sum[i + k] - sum[i], ans); } cout << ans << endl; }
replace
107
108
107
108
0
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, s, n) for (int i = s; i < (n); i++) #define ALL(a) a.begin(), a.end() #define RALL(a) a.rbegin(), a.rend() #define maxs(x, y) x = max(x, y) #define mins(x, y) x = min(x, y) using namespace std; using ll = long long; typedef pair<int, int> pint; typedef pair<ll, ll> pll; const ll MOD = 1000000007; const ll INF = MOD * MOD; const int inf = (1 << 29); int main() { double N, K; cin >> N >> K; vector<double> p(N); REP(i, N) cin >> p[i]; double temp = 0; double sum = 0; for (double i = 0; i < N - K + 1; i++) { double kari = 0; for (double j = i; j < i + K; j++) { kari += p[j]; } // cout << kari << endl; if (kari > sum) { sum = kari; temp = i; } } double ans = 0; ans = (sum + K) / 2; printf("%.15f\n", ans); return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, s, n) for (int i = s; i < (n); i++) #define ALL(a) a.begin(), a.end() #define RALL(a) a.rbegin(), a.rend() #define maxs(x, y) x = max(x, y) #define mins(x, y) x = min(x, y) using namespace std; using ll = long long; typedef pair<int, int> pint; typedef pair<ll, ll> pll; const ll MOD = 1000000007; const ll INF = MOD * MOD; const int inf = (1 << 29); int main() { double N, K; cin >> N >> K; vector<double> p(N); REP(i, N) cin >> p[i]; double temp = 0; double sum = 0; for (int i = 0; i < K; i++) { sum += p[i]; } temp = sum; for (double i = K; i < N; i++) { temp -= p[i - K]; temp += p[i]; if (temp > sum) sum = temp; } double ans = 0; ans = (sum + K) / 2; printf("%.15f\n", ans); return 0; }
replace
25
36
25
34
TLE
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define MOD 1000000007 #define el endl #define INF 1e8 typedef long long ll; typedef long double ld; int main() { int n, k; cin >> n >> k; vector<long double> p(n), s(n), a(n); s[0] = 0; rep(i, n) { long double temp; cin >> temp; p[i] = (1 + temp) / 2; } for (int i = 1; i < n + 1; i++) { s[i] = s[i - 1] + p[i - 1]; } long double ans = 0; for (int i = 0; i < n - k + 1; i++) { ans = ans > s[i + k] - s[i] ? ans : s[i + k] - s[i]; } // rep(i,n) cout << a[i] << endl; cout << fixed << setprecision(12); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define MOD 1000000007 #define el endl #define INF 1e8 typedef long long ll; typedef long double ld; int main() { int n, k; cin >> n >> k; vector<long double> p(n), s(n + 1), a(n); s[0] = 0; rep(i, n) { long double temp; cin >> temp; p[i] = (1 + temp) / 2; } for (int i = 1; i < n + 1; i++) { s[i] = s[i - 1] + p[i - 1]; } long double ans = 0; for (int i = 0; i < n - k + 1; i++) { ans = ans > s[i + k] - s[i] ? ans : s[i + k] - s[i]; } // rep(i,n) cout << a[i] << endl; cout << fixed << setprecision(12); cout << ans << endl; }
replace
14
15
14
15
-6
munmap_chunk(): invalid pointer
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int a[200005], n, k; double ans, num; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) num += a[i]; ans = num; for (int i = 2; i < n; i++) { num -= a[i - 1]; num += a[i + k - 1]; ans = max(ans, num); } printf("%10.12f", (ans + k) / 2); return 0; }
#include <bits/stdc++.h> using namespace std; int a[2000005], n, k; double ans, num; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) num += a[i]; ans = num; for (int i = 2; i < n; i++) { num -= a[i - 1]; num += a[i + k - 1]; ans = max(ans, num); } printf("%10.12f", (ans + k) / 2); return 0; }
replace
2
3
2
3
0
p02780
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <regex> #include <set> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, s, n) for (int i = (s); i < (int)(n); i++) #define revrep(i, n) for (int i = (n); i >= 0; i--) #define revrepr(i, a, b) for (int i = (a); i >= b; i--) #define debug(x) cerr << #x << ": " << x << "\n" using ll = long long; using P = pair<int, int>; const long long MOD = 1e9 + 7; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i); return is; } int main() { int n, k; cin >> n >> k; vector<double> p(n); cin >> p; double maxi = 0; rep(i, n - k + 1) { double res = 0; rep(j, k) { res += (p.at(i + j) + 1) / 2.0; } chmax(maxi, res); } printf("%.10lf\n", maxi); }
#include <algorithm> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <regex> #include <set> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, s, n) for (int i = (s); i < (int)(n); i++) #define revrep(i, n) for (int i = (n); i >= 0; i--) #define revrepr(i, a, b) for (int i = (a); i >= b; i--) #define debug(x) cerr << #x << ": " << x << "\n" using ll = long long; using P = pair<int, int>; const long long MOD = 1e9 + 7; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i); return is; } int main() { int n, k; cin >> n >> k; vector<double> p(n); cin >> p; double maxi = 0; double sum = 0; rep(i, n) { sum += (p.at(i) + 1) / 2; if (i < k - 1) continue; if (k <= i) { sum -= (p.at(i - k) + 1) / 2; } chmax(maxi, sum); } printf("%.10lf\n", maxi); }
replace
52
56
52
62
TLE
p02780
C++
Time Limit Exceeded
/* / \ (Hello)//JSM//*/ /* /*****\ */ /* Jai Shree Mataji / \ |\| |_| $ |-| K */ #include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <set> #include <string.h> #include <vector> using namespace std; #define ll long long int #define ld long double #define MOD 1000000007 #define PI 3.1415926535897932384626433832795 #define YY cout << "YES" #define NN cout << "NO" #define EE cout << "\n" #define ee cout << "\n" #define ne cout << "-1" #define pb push_back #define fi first #define se second #define mkp make_pair #define mkt make_tuple #define sall(v) sort(v.begin(), v.end()) #define all(v) v.begin(), v.end() #define fo(i, n) for (ll i = 0; i < n; i++) #define vl vector<ll> #define vc vector<char> #define vll vector<pair<ll, ll>> #define mps map<string, ll> #define mpc map<char, ll> #define mpl map<ll, ll> #define pr pair<ll, ll> #define tpl tuple<ll, ll, ll> bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } ll containsDigit(ll number, ll digit) { while (number != 0) { int curr_digit = number % 10; if (curr_digit == digit) return 1; number /= 10; } return 0; } ll soltn(ll x, ll n) { if (x >= 0) return x % n; else return n + x % n; } ll bin_srch(ll L[], ll N, ll item) { ll flag = -2; int l = 0, u = N - 1, m; while (l <= u) { m = (l + u) / 2; if (item == L[m]) { flag = m - 1; break; } else if (item > L[m]) l = m - 1; else u = m + 1; } return flag; } ll pd(ll x, ll y) { if (x % y == 0) return x / y; else return x / y + 1; } ll coda(ll n, ll d) { ll count = 0; while (n != 0) { if (n % 10 == d) count++; n /= 10; } return count; } ll minDissame(ll a[], ll n) { map<ll, ll> hmap; ll minDistance = INT_MAX; ll previousIndex = 0, currentIndex = 0; for (ll i = 0; i < n; i++) { if (hmap.find(a[i]) != hmap.end()) { currentIndex = i; previousIndex = hmap[a[i]]; minDistance = min((currentIndex - previousIndex), minDistance); } hmap[a[i]] = i; } return (minDistance == INT_MAX ? -1 : minDistance); } ll minDistanytwo(ll arr[], ll n, ll x, ll y) { ll p = -1, min_dist = INT_MAX; for (ll i = 0; i < n; i++) { if (arr[i] == x || arr[i] == y) { if (p != -1 && arr[i] != arr[p]) min_dist = min(min_dist, i - p); p = i; } } if (min_dist == INT_MAX) return -1; return min_dist; } ll mdls(ll x) { return max(x, -x); } ll pow1(ll n, ll p) { if (p == 0) return 1; ll x = pow1(n, p / 2); x = (x * x); if (p % 2 == 0) return x; else return (x * n); } string fumn(string s) { string p; for (ll i = 0; i < s.length(); i++) if (isalpha(s[i])) p += toupper(s[i]); return p; } ll turns(string S, string SS) { ll i, cc = 0, l = S.length(); fo(i, l) { if (S[i] != SS[i]) cc++; } return cc / 2; } ll isSubstr(string s1, string s2) { ll M = s1.length(); ll N = s2.length(); for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j]) break; if (j == M) return i; } return -1; } // s2>s1;if(not) rtrn -1; ll hhh2(unsigned ll n) { if (n < 1) return 0; ll res = 1; ll u = 0; for (ll i = 0; i < 8 * sizeof(unsigned ll); i++) { ll curr = 1 << i; if (curr > n) break; u++; res = curr; } return u; } ld ldgcd(ld a, ld b) { return a < 0.0001 ? b : ldgcd(fmod(b, a), a); } void onesol(ll a, ll b, ll &x, ll &y, ll &g) { if (!b) { g = a; x = 1; y = 0; } else { onesol(b, a % b, y, x, g); y -= a / b * x; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll tt = 1; // cin>>tt; while (tt--) { /* 5 3 1 2 2 4 5*/ ll n, m, j, k, l, i; cin >> n >> m; ld a[n]; fo(i, n) cin >> a[i]; ld s = 0; ld mi = 0; fo(i, n - (m - 1)) { s = 0; fo(j, m) { s += a[j + i]; s++; } mi = max(s, mi); } cout << fixed << setprecision(10) << mi / 2; ee; } return 0; }
/* / \ (Hello)//JSM//*/ /* /*****\ */ /* Jai Shree Mataji / \ |\| |_| $ |-| K */ #include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <set> #include <string.h> #include <vector> using namespace std; #define ll long long int #define ld long double #define MOD 1000000007 #define PI 3.1415926535897932384626433832795 #define YY cout << "YES" #define NN cout << "NO" #define EE cout << "\n" #define ee cout << "\n" #define ne cout << "-1" #define pb push_back #define fi first #define se second #define mkp make_pair #define mkt make_tuple #define sall(v) sort(v.begin(), v.end()) #define all(v) v.begin(), v.end() #define fo(i, n) for (ll i = 0; i < n; i++) #define vl vector<ll> #define vc vector<char> #define vll vector<pair<ll, ll>> #define mps map<string, ll> #define mpc map<char, ll> #define mpl map<ll, ll> #define pr pair<ll, ll> #define tpl tuple<ll, ll, ll> bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } ll containsDigit(ll number, ll digit) { while (number != 0) { int curr_digit = number % 10; if (curr_digit == digit) return 1; number /= 10; } return 0; } ll soltn(ll x, ll n) { if (x >= 0) return x % n; else return n + x % n; } ll bin_srch(ll L[], ll N, ll item) { ll flag = -2; int l = 0, u = N - 1, m; while (l <= u) { m = (l + u) / 2; if (item == L[m]) { flag = m - 1; break; } else if (item > L[m]) l = m - 1; else u = m + 1; } return flag; } ll pd(ll x, ll y) { if (x % y == 0) return x / y; else return x / y + 1; } ll coda(ll n, ll d) { ll count = 0; while (n != 0) { if (n % 10 == d) count++; n /= 10; } return count; } ll minDissame(ll a[], ll n) { map<ll, ll> hmap; ll minDistance = INT_MAX; ll previousIndex = 0, currentIndex = 0; for (ll i = 0; i < n; i++) { if (hmap.find(a[i]) != hmap.end()) { currentIndex = i; previousIndex = hmap[a[i]]; minDistance = min((currentIndex - previousIndex), minDistance); } hmap[a[i]] = i; } return (minDistance == INT_MAX ? -1 : minDistance); } ll minDistanytwo(ll arr[], ll n, ll x, ll y) { ll p = -1, min_dist = INT_MAX; for (ll i = 0; i < n; i++) { if (arr[i] == x || arr[i] == y) { if (p != -1 && arr[i] != arr[p]) min_dist = min(min_dist, i - p); p = i; } } if (min_dist == INT_MAX) return -1; return min_dist; } ll mdls(ll x) { return max(x, -x); } ll pow1(ll n, ll p) { if (p == 0) return 1; ll x = pow1(n, p / 2); x = (x * x); if (p % 2 == 0) return x; else return (x * n); } string fumn(string s) { string p; for (ll i = 0; i < s.length(); i++) if (isalpha(s[i])) p += toupper(s[i]); return p; } ll turns(string S, string SS) { ll i, cc = 0, l = S.length(); fo(i, l) { if (S[i] != SS[i]) cc++; } return cc / 2; } ll isSubstr(string s1, string s2) { ll M = s1.length(); ll N = s2.length(); for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j]) break; if (j == M) return i; } return -1; } // s2>s1;if(not) rtrn -1; ll hhh2(unsigned ll n) { if (n < 1) return 0; ll res = 1; ll u = 0; for (ll i = 0; i < 8 * sizeof(unsigned ll); i++) { ll curr = 1 << i; if (curr > n) break; u++; res = curr; } return u; } ld ldgcd(ld a, ld b) { return a < 0.0001 ? b : ldgcd(fmod(b, a), a); } void onesol(ll a, ll b, ll &x, ll &y, ll &g) { if (!b) { g = a; x = 1; y = 0; } else { onesol(b, a % b, y, x, g); y -= a / b * x; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll tt = 1; // cin>>tt; while (tt--) { /* 5 3 1 2 2 4 5*/ ll n, m, j, k, l, i; cin >> n >> m; ld a[n]; fo(i, n) cin >> a[i]; ld s = 0; ld mi = 0; fo(i, m) mi += a[i]; s = mi + m; mi += m; fo(i, n + 1 - m) { s += a[m + i] - a[i]; mi = max(mi, s); } cout << fixed << setprecision(10) << mi / 2; ee; } return 0; }
replace
194
201
194
200
TLE
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N, K, mx_pk = 0; cin >> N >> K; vector<int> p(N); rep(i, N) cin >> p.at(i); rep(i, N - K + 1) { int tmp = 0; for (int j = i; j < i + K; j++) { tmp += p.at(j); } mx_pk = max(mx_pk, tmp); } cout << fixed << setprecision(10) << (mx_pk + K) / 2.0 << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N, K, mx_pk = 0; cin >> N >> K; vector<int> p(N + 1, 0), p_sum(N + 1, 0); rep(i, N) cin >> p.at(i + 1); rep(i, N) p_sum.at(i + 1) = p_sum.at(i) + p.at(i + 1); for (int i = N; i - K >= 0; i--) mx_pk = max(mx_pk, p_sum.at(i) - p_sum.at(i - K)); cout << fixed << setprecision(10) << (mx_pk + K) / 2.0 << endl; }
replace
8
17
8
14
TLE
p02780
C++
Time Limit Exceeded
// include #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; //------------------------------------------ // typedef typedef long long ll; typedef vector<int> VI; typedef vector<bool> VB; typedef vector<char> VC; typedef vector<double> VD; typedef vector<long long> VL; typedef vector<VI> VVI; typedef vector<VB> VVB; typedef vector<string> VS; typedef vector<VL> VVL; typedef pair<int, int> PI; typedef pair<ll, ll> PL; typedef pair<int, string> PIS; typedef pair<string, int> PSI; typedef pair<string, string> PSS; //------------------------------------------ // comparison #define C_MAX(a, b) ((a) > (b) ? (a) : (b)) #define C_MIN(a, b) ((a) < (b) ? (a) : (b)) #define C_ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) //------------------------------------------ // container util #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0) #define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.) #define SUML(obj) accumulate((obj).begin(), (obj).end(), 0ll) #define UB(obj, n) upper_bound((obj).begin(), (obj).end(), n) #define LB(obj, n) lower_bound((obj).begin(), (obj).end(), n) #define BS(v, n) binary_search(ALL(v), (n)) #define PB push_back #define MP make_pair //------------------------------------------ // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define FORL(i, a, b) for (ll i = ll(a); i < ll(b); ++i) #define RFORL(i, a, b) for (ll i = ll(b) - 1; i >= ll(a); --i) #define REPL(i, n) for (ll i = 0; i < ll(n); ++i) #define RREPL(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define FOREACH(x, v) for (auto &(x) : (v)) #define FORITER(x, v) for (auto(x) = (v).begin(); (x) != (v).end(); ++(x)) //------------------------------------------ // input output #define GL(s) getline(cin, (s)) #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define IN(...) GET_MACRO(__VA_ARGS__, IN3, IN2, IN1)(__VA_ARGS__) #define IN1(n) std::cin >> (n); #define IN2(n, m) std::cin >> (n) >> (m); #define IN3(n, m, l) std::cin >> (n) >> (m) >> (l); #define OUT(d) std::cout << (d); #define OUT_L(d) std::cout << (d) << endl; #define OUT_Y std::cout << "Yes" << endl; #define OUT_N std::cout << "No" << endl; #define FOUT(n, d) std::cout << std::fixed << std::setprecision(n) << (d); #define EL() std::cout << "\n"; //------------------------------------------ // constant #define MAX 200000 #define MOD 1000000007 //------------------------------------------ // 数値・文字列 inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline ll toLongLong(string s) { ll v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline VC toVC(string s) { VC data(s.begin(), s.end()); return data; } //------------------------------------------ // extended permutation combination // possible implementation introduced at // http://en.cppreference.com/w/cpp/algorithm/rotate with slight modification to // handle parted ranges template <typename FI> void parted_rotate(FI first1, FI last1, FI first2, FI last2) { if (first1 == last1 || first2 == last2) return; FI next = first2; while (first1 != next) { std::iter_swap(first1++, next++); if (first1 == last1) first1 = first2; if (next == last2) { next = first2; } else if (first1 == first2) { first2 = next; } } } template <typename BI> bool next_combination_imp(BI first1, BI last1, BI first2, BI last2) { if (first1 == last1 || first2 == last2) return false; auto target = last1; --target; auto last_elem = last2; --last_elem; // find right-most incrementable element: target while (target != first1 && !(*target < *last_elem)) --target; if (target == first1 && !(*target < *last_elem)) { parted_rotate(first1, last1, first2, last2); return false; } // find the next value to be incremented: *next auto next = first2; while (!(*target < *next)) ++next; std::iter_swap(target++, next++); parted_rotate(target, last1, next, last2); return true; } // INVARIANT: is_sorted(first, mid) && is_sorted(mid, last) template <typename BI> inline bool next_combination(BI first, BI mid, BI last) { return next_combination_imp(first, mid, mid, last); } // INVARIANT: is_sorted(first, mid) && is_sorted(mid, last) template <typename BI> inline bool prev_combination(BI first, BI mid, BI last) { return next_combination_imp(mid, last, first, mid); } //------------------------------------------ // other functions //------------------------------------------ // a^n mod を二分累乗法で計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long moddiv(long long a, long long b, long long mod) { a %= mod; return a * modinv(b, mod) % mod; } // 任意の二項係数nCkをO(n)->O(1)で求める long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void nCkinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long nCk(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // 最大公約数 template <class T> inline T GCD(const T x, const T y) { if (x < 0) return GCD(-x, y); if (y < 0) return GCD(x, -y); return (!y) ? x : GCD(y, x % y); } // 最小公倍数 template <class T> inline T LCM(const T x, const T y) { if (x < 0) return LCM(-x, y); if (y < 0) return LCM(x, -y); return x * (y / GCD(x, y)); } // memo------------------------------------- /* //尺取り法 //二分法 vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910}; // index が条件を満たすかどうか bool isOK(int index, int key) { if (a[index] >= key) return true; else return false; } // 汎用的な二分探索のテンプレ int binary_search(int key) { int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1 int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size() // ok と ng のどちらが大きいかわからないことを考慮 while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key)) ok = mid; else ng = mid; } return ok; } //----------------------------------------- */ // main code-------------------------------- #define INF 1LL << 61 void _main() { ll n, k; IN(n, k) VL si(n); REP(i, n) IN(si[i]) double out = 0; REP(i, n - k + 1) { double sum = 0; REP(j, k) { sum += (double)(si[i + j] + 1) / 2; } out = max(out, sum); } OUT_L(out); return; } int main() { cout << fixed << setprecision(10); nCkinit(); _main(); return 0; }
// include #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; //------------------------------------------ // typedef typedef long long ll; typedef vector<int> VI; typedef vector<bool> VB; typedef vector<char> VC; typedef vector<double> VD; typedef vector<long long> VL; typedef vector<VI> VVI; typedef vector<VB> VVB; typedef vector<string> VS; typedef vector<VL> VVL; typedef pair<int, int> PI; typedef pair<ll, ll> PL; typedef pair<int, string> PIS; typedef pair<string, int> PSI; typedef pair<string, string> PSS; //------------------------------------------ // comparison #define C_MAX(a, b) ((a) > (b) ? (a) : (b)) #define C_MIN(a, b) ((a) < (b) ? (a) : (b)) #define C_ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) //------------------------------------------ // container util #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0) #define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.) #define SUML(obj) accumulate((obj).begin(), (obj).end(), 0ll) #define UB(obj, n) upper_bound((obj).begin(), (obj).end(), n) #define LB(obj, n) lower_bound((obj).begin(), (obj).end(), n) #define BS(v, n) binary_search(ALL(v), (n)) #define PB push_back #define MP make_pair //------------------------------------------ // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define FORL(i, a, b) for (ll i = ll(a); i < ll(b); ++i) #define RFORL(i, a, b) for (ll i = ll(b) - 1; i >= ll(a); --i) #define REPL(i, n) for (ll i = 0; i < ll(n); ++i) #define RREPL(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define FOREACH(x, v) for (auto &(x) : (v)) #define FORITER(x, v) for (auto(x) = (v).begin(); (x) != (v).end(); ++(x)) //------------------------------------------ // input output #define GL(s) getline(cin, (s)) #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define IN(...) GET_MACRO(__VA_ARGS__, IN3, IN2, IN1)(__VA_ARGS__) #define IN1(n) std::cin >> (n); #define IN2(n, m) std::cin >> (n) >> (m); #define IN3(n, m, l) std::cin >> (n) >> (m) >> (l); #define OUT(d) std::cout << (d); #define OUT_L(d) std::cout << (d) << endl; #define OUT_Y std::cout << "Yes" << endl; #define OUT_N std::cout << "No" << endl; #define FOUT(n, d) std::cout << std::fixed << std::setprecision(n) << (d); #define EL() std::cout << "\n"; //------------------------------------------ // constant #define MAX 200000 #define MOD 1000000007 //------------------------------------------ // 数値・文字列 inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline ll toLongLong(string s) { ll v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline VC toVC(string s) { VC data(s.begin(), s.end()); return data; } //------------------------------------------ // extended permutation combination // possible implementation introduced at // http://en.cppreference.com/w/cpp/algorithm/rotate with slight modification to // handle parted ranges template <typename FI> void parted_rotate(FI first1, FI last1, FI first2, FI last2) { if (first1 == last1 || first2 == last2) return; FI next = first2; while (first1 != next) { std::iter_swap(first1++, next++); if (first1 == last1) first1 = first2; if (next == last2) { next = first2; } else if (first1 == first2) { first2 = next; } } } template <typename BI> bool next_combination_imp(BI first1, BI last1, BI first2, BI last2) { if (first1 == last1 || first2 == last2) return false; auto target = last1; --target; auto last_elem = last2; --last_elem; // find right-most incrementable element: target while (target != first1 && !(*target < *last_elem)) --target; if (target == first1 && !(*target < *last_elem)) { parted_rotate(first1, last1, first2, last2); return false; } // find the next value to be incremented: *next auto next = first2; while (!(*target < *next)) ++next; std::iter_swap(target++, next++); parted_rotate(target, last1, next, last2); return true; } // INVARIANT: is_sorted(first, mid) && is_sorted(mid, last) template <typename BI> inline bool next_combination(BI first, BI mid, BI last) { return next_combination_imp(first, mid, mid, last); } // INVARIANT: is_sorted(first, mid) && is_sorted(mid, last) template <typename BI> inline bool prev_combination(BI first, BI mid, BI last) { return next_combination_imp(mid, last, first, mid); } //------------------------------------------ // other functions //------------------------------------------ // a^n mod を二分累乗法で計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long moddiv(long long a, long long b, long long mod) { a %= mod; return a * modinv(b, mod) % mod; } // 任意の二項係数nCkをO(n)->O(1)で求める long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void nCkinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long nCk(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // 最大公約数 template <class T> inline T GCD(const T x, const T y) { if (x < 0) return GCD(-x, y); if (y < 0) return GCD(x, -y); return (!y) ? x : GCD(y, x % y); } // 最小公倍数 template <class T> inline T LCM(const T x, const T y) { if (x < 0) return LCM(-x, y); if (y < 0) return LCM(x, -y); return x * (y / GCD(x, y)); } // memo------------------------------------- /* //尺取り法 //二分法 vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910}; // index が条件を満たすかどうか bool isOK(int index, int key) { if (a[index] >= key) return true; else return false; } // 汎用的な二分探索のテンプレ int binary_search(int key) { int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1 int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size() // ok と ng のどちらが大きいかわからないことを考慮 while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key)) ok = mid; else ng = mid; } return ok; } //----------------------------------------- */ // main code-------------------------------- #define INF 1LL << 61 void _main() { ll n, k; IN(n, k) VL si(n); REP(i, n) IN(si[i]) double out = 0; REP(j, k) { out += (double)(si[j] + 1) / 2; } double prev = out; REP(i, n - k) { double next = prev; next += (double)(si[i + k] + 1) / 2; next -= (double)(si[i] + 1) / 2; out = max(next, out); prev = next; } OUT_L(out); return; } int main() { cout << fixed << setprecision(10); nCkinit(); _main(); return 0; }
replace
280
284
280
288
TLE
p02780
C++
Time Limit Exceeded
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cassert> #include <complex> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <time.h> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> using namespace std; using ll = long long; #define Ma_PI 3.141592653589793 #define eps 0.00000001 #define LONG_INF 3000000000000000000 #define rep(i, n) for (long long i = 0; i < n; ++i) #define seg_size 524288 int main() { int n, k; cin >> n >> k; vector<int> p(n); rep(i, n) cin >> p[i]; vector<int> a(n - k + 1); rep(i, n - k + 1) rep(j, k) a[i] += p[j + i]; double max = 0; rep(i, a.size()) { if (a[i] > max) max = a[i]; } max = (max + k) / 2; printf("%.10f\n", max); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cassert> #include <complex> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <time.h> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> using namespace std; using ll = long long; #define Ma_PI 3.141592653589793 #define eps 0.00000001 #define LONG_INF 3000000000000000000 #define rep(i, n) for (long long i = 0; i < n; ++i) #define seg_size 524288 int main() { int n, k; cin >> n >> k; vector<int> p(n); rep(i, n) cin >> p[i]; vector<int> a(n - k + 1); rep(i, k) a[0] += p[i]; for (int i = 1; i < n - k + 1; i++) { a[i] = a[i - 1] - p[i - 1] + p[i + k - 1]; } double max = 0; rep(i, a.size()) { if (a[i] > max) max = a[i]; } max = (max + k) / 2; printf("%.10f\n", max); return 0; }
replace
40
41
40
44
TLE
p02780
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP1(i, a, b) for (int i = a; i <= (int)(b); i++) #define ALL(x) begin(x), end(x) #define PB push_back using namespace std; typedef int64_t LL; typedef vector<int> VI; typedef pair<int, int> PII; template <class T> inline bool chmax(T &a, const T &b) { return b > a ? a = b, true : false; } template <class T> inline bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; } template <class T> using MaxHeap = priority_queue<T>; template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); } const int MAX_N = 200005; double A[MAX_N]; double E(int x) { return (double)(x + 1) / 2; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; REP(i, n) { int a; cin >> a; A[i] = E(a); } double ans = 0, temp = 0; REP(i, n) { temp += A[i]; if (n >= k) temp -= A[i - k]; chmax(ans, temp); } cout << setprecision(10) << ans << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP1(i, a, b) for (int i = a; i <= (int)(b); i++) #define ALL(x) begin(x), end(x) #define PB push_back using namespace std; typedef int64_t LL; typedef vector<int> VI; typedef pair<int, int> PII; template <class T> inline bool chmax(T &a, const T &b) { return b > a ? a = b, true : false; } template <class T> inline bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; } template <class T> using MaxHeap = priority_queue<T>; template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); } const int MAX_N = 200005; double A[MAX_N]; double E(int x) { return (double)(x + 1) / 2; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; REP(i, n) { int a; cin >> a; A[i] = E(a); } double ans = 0, temp = 0; REP(i, n) { temp += A[i]; if (i >= k) temp -= A[i - k]; chmax(ans, temp); } cout << setprecision(10) << ans << endl; return 0; }
replace
44
45
44
45
0
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); vector<double> kit(n); for (int i = 0; i < n; i++) { cin >> a.at(i); kit.at(i) = (a.at(i) + 1.0) / 2; } double ans = 0; for (int i = 0; i <= n - k; i++) { double bf = 0; for (int j = 0; j < k; j++) { bf += kit.at(i + j); } ans = max(ans, bf); } cout << setprecision(9) << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); vector<double> kit(n); for (int i = 0; i < n; i++) { cin >> a.at(i); kit.at(i) = (a.at(i) + 1.0) / 2; } double ans = 0, bf = 0; for (int i = 0; i < k; i++) bf += kit.at(i); ans = bf; for (int i = k; i < n; i++) { bf += kit.at(i) - kit.at(i - k); ans = max(ans, bf); } cout << setprecision(9) << ans << endl; return 0; }
replace
12
18
12
18
TLE
p02780
C++
Runtime Error
#include <bits/stdc++.h> #define ll int64_t #define rep(i, n) for (ll i = 0; i < n; i++) #define rrep(i, n) for (ll i = 1; i <= n; i++) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define pb push_back #define mod 1000000007 using namespace std; bool compare_by_b(pair<string, ll> a, pair<string, ll> b) { if (a.second != b.second) return a.second < b.second; else return a.first < b.first; } bool my_compare(pair<string, ll> a, pair<string, ll> b) { if (a.first != b.first) return a.first < b.first; if (a.second != b.second) return a.second > b.second; else return true; } ll factorial(ll n) { ll x = 1; rrep(i, n) x *= i; return x; } ll gcd(ll a, ll b) { if (a % b == 0) return (b); else return (gcd(b, a % b)); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { double n, k, maxi = -100, sum = 0; cin >> n >> k; vector<double> p(n), q(n), r(n, 0); rep(i, n) { cin >> p[i]; q[i] = (1 + p[i]) / 2; sum += q[i]; r[i + 1] = sum; } if (n == 1) { cout << q[0] << endl; return 0; } rep(i, n - k + 1) { if (maxi < (r[i + k] - r[i])) maxi = r[i + k] - r[i]; } cout << fixed << setprecision(30) << maxi << endl; return 0; }
#include <bits/stdc++.h> #define ll int64_t #define rep(i, n) for (ll i = 0; i < n; i++) #define rrep(i, n) for (ll i = 1; i <= n; i++) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define pb push_back #define mod 1000000007 using namespace std; bool compare_by_b(pair<string, ll> a, pair<string, ll> b) { if (a.second != b.second) return a.second < b.second; else return a.first < b.first; } bool my_compare(pair<string, ll> a, pair<string, ll> b) { if (a.first != b.first) return a.first < b.first; if (a.second != b.second) return a.second > b.second; else return true; } ll factorial(ll n) { ll x = 1; rrep(i, n) x *= i; return x; } ll gcd(ll a, ll b) { if (a % b == 0) return (b); else return (gcd(b, a % b)); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { double n, k, maxi = -100, sum = 0; cin >> n >> k; vector<double> p(n), q(n), r(n + 1, 0); rep(i, n) { cin >> p[i]; q[i] = (1 + p[i]) / 2; sum += q[i]; r[i + 1] = sum; } if (n == 1) { cout << q[0] << endl; return 0; } rep(i, n - k + 1) { if (maxi < (r[i + k] - r[i])) maxi = r[i + k] - r[i]; } cout << fixed << setprecision(30) << maxi << endl; return 0; }
replace
46
47
46
47
-6
malloc(): corrupted top size
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1000000007; constexpr ll INF = 1ll << 60; long double P[200010]; long double sum[200010]; int main(int argc, char **argv) { ll N, K; cin >> N >> K; for (ll i = 0; i < N; ++i) { long double p; cin >> p; P[i] = (p * (1 + p) / 2) / p; } sum[0] = 0.0; for (ll i = 0; i < N; ++i) sum[i + 1] = sum[i] + P[i]; long double res{0.0}; for (ll i = 0; i < N + K - 1; ++i) { res = max(res, sum[i + K] - sum[i]); } std::cout << fixed << setprecision(10) << res << std::endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1000000007; constexpr ll INF = 1ll << 60; long double P[200010]; long double sum[200010]; int main(int argc, char **argv) { ll N, K; cin >> N >> K; for (ll i = 0; i < N; ++i) { long double p; cin >> p; P[i] = (p * (1 + p) / 2) / p; } sum[0] = 0.0; for (ll i = 0; i < N; ++i) sum[i + 1] = sum[i] + P[i]; long double res{0.0}; for (ll i = 0; i < N - K + 1; ++i) { res = max(res, sum[i + K] - sum[i]); } std::cout << fixed << setprecision(10) << res << std::endl; }
replace
23
24
23
24
0
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const ll INF = 1LL << 60; ll p[200010]; int main() { ll N, K; cin >> N >> K; rep(i, N) { cin >> p[i]; } ll tmpmax = -INF; ll tmp; for (ll i = 0; i <= N - K; i++) { tmp = 0; rep(j, K) { tmp += p[i + j]; } if (tmp > tmpmax) { tmpmax = tmp; } } double result = (tmpmax + K) / 2.0; cout << setprecision(10) << fixed << result << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const ll INF = 1LL << 60; ll p[200010]; int main() { ll N, K; cin >> N >> K; rep(i, N) { cin >> p[i]; } ll tmpmax = -INF; ll tmp = 0; ll a = p[0]; ll b = p[K - 1]; rep(i, K) { tmp += p[i]; } tmpmax = tmp; for (ll i = 0; i < N - K; i++) { tmp -= a; a = p[i + 1]; b = p[i + K]; tmp += b; if (tmp > tmpmax) { tmpmax = tmp; } } double result = (tmpmax + K) / 2.0; cout << setprecision(10) << fixed << result << endl; return 0; }
replace
27
31
27
39
TLE
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll ZERO = 0; const int Inf = 1000000000; const ll INF = 1e18; const ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<ll, ll> P; int main() { int N, K; cin >> N >> K; vector<double> vec(N); for (int i = 0; i < N; i++) { cin >> vec.at(i); } for (int i = 0; i < N; i++) { vec.at(i) = (1 + vec.at(i)) * vec.at(i) / 2 / vec.at(i); } double ret = 0; for (int i = 0; i < N - K + 1; i++) { double cnt = 0; for (int j = 0; j < K; j++) { cnt += vec.at(i + j); } ret = max(ret, cnt); } cout << fixed; cout << setprecision(10) << ret << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll ZERO = 0; const int Inf = 1000000000; const ll INF = 1e18; const ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<ll, ll> P; int main() { int N, K; cin >> N >> K; vector<double> vec(N); for (int i = 0; i < N; i++) { cin >> vec.at(i); } for (int i = 0; i < N; i++) { vec.at(i) = (1 + vec.at(i)) * vec.at(i) / 2 / vec.at(i); } double ret = 0; double cnt = 0; for (int i = 0; i < K; i++) { ret += vec.at(i); cnt += vec.at(i); } for (int i = K; i < N; i++) { cnt -= vec.at(i - K); cnt += vec.at(i); ret = max(ret, cnt); } cout << fixed; cout << setprecision(10) << ret << endl; }
replace
21
26
21
29
TLE
p02780
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <unordered_set> #include <vector> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define pb push_back #define eb emplace_back using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const string &s) { return '"' + s + '"'; } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(vector<bool> v) { bool first = true; string res = "{"; for (int i = 0; i < static_cast<int>(v.size()); i++) { if (!first) { res += ", "; } first = false; res += to_string(v[i]); } res += "}"; return res; } template <size_t N> string to_string(bitset<N> v) { string res = ""; for (size_t i = 0; i < N; i++) { res += static_cast<char>('0' + v[i]); } return res; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")"; } template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")"; } void debug_out() { cerr << "\n"; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif void solve() { ll n, k; cin >> n >> k; vector<double> p(n); rep(i, n) cin >> p[i]; double sum = 0, ans = 0; rep(i, n - k + 1) { sum = 0; rep(j, k) { sum += ((p[i + j] * (p[i + j] + 1)) / 2) / p[i + j]; } chmax(ans, sum); } cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <unordered_set> #include <vector> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define pb push_back #define eb emplace_back using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const string &s) { return '"' + s + '"'; } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(vector<bool> v) { bool first = true; string res = "{"; for (int i = 0; i < static_cast<int>(v.size()); i++) { if (!first) { res += ", "; } first = false; res += to_string(v[i]); } res += "}"; return res; } template <size_t N> string to_string(bitset<N> v) { string res = ""; for (size_t i = 0; i < N; i++) { res += static_cast<char>('0' + v[i]); } return res; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")"; } template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")"; } void debug_out() { cerr << "\n"; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif void solve() { ll n, k; cin >> n >> k; vector<double> p(n); rep(i, n) cin >> p[i]; double sum = 0, ans = 0; rep(i, k) sum += ((p[i] * (p[i] + 1)) / 2) / p[i]; chmax(ans, sum); for (int i = 1; i < n - k + 1; ++i) { sum -= ((p[i - 1] * (p[i - 1] + 1)) / 2) / p[i - 1]; sum += ((p[i + k - 1] * (p[i + k - 1] + 1)) / 2) / p[i + k - 1]; chmax(ans, sum); } cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }
replace
130
133
130
136
TLE
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define LL long long using namespace std; double a[200020]; int sum[1010]; int main() { for (int i = 1; i <= 1000; i++) { sum[i] = sum[i - 1] + i; } int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { scanf("%lf", &a[i]); a[i] = sum[(int)a[i]] / a[i]; } double ans = 0, t = 0; for (int i = 0; i < n; i++) { int j = i; t = 0; while (j < n && j - i < k) t += a[j], j++; ans = max(ans, t); } printf("%.12lf\n", ans); return 0; }
#include <bits/stdc++.h> #define LL long long using namespace std; double a[200020]; int sum[1010]; int main() { for (int i = 1; i <= 1000; i++) { sum[i] = sum[i - 1] + i; } int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { scanf("%lf", &a[i]); a[i] = sum[(int)a[i]] / a[i]; } double ans = 0, t = 0; int i = 0, j = 0; while (j < k) t += a[j], j++; ans = max(ans, t); while (i < n && j < n) { t += a[j]; t -= a[i]; i++, j++; ans = max(ans, t); } printf("%.12lf\n", ans); return 0; }
replace
17
22
17
25
TLE
p02780
C++
Time Limit Exceeded
// default #include <bits/stdc++.h> using namespace std; #define int long long #define double long double typedef pair<int, int> P_i; typedef pair<double, double> P_d; #define rep(i, n) for (int i = 0; i < (n); ++i) #define alrep(i, j, n) \ for (int i = 0; i < (n); ++i) \ for (int j = i + 1; j < (n); ++j) #define Yes cout << "Yes" << endl; #define No \ cout << "No" << endl; \ int ans = 0; #define answer cout << ans << endl; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int MOD = 1e9 + 7; const long long INF = 1LL << 60; signed main() { int N, K; double ans = -1; cin >> N >> K; double p[N]; rep(i, N) { cin >> p[i]; } rep(i, N - K + 1) { double res = 0; for (int j = i; j < i + K; j++) { res += (double)(p[j] + 1) / (double)2; } chmax(ans, res); } cout << fixed << setprecision(6) << ans << endl; return 0; }
// default #include <bits/stdc++.h> using namespace std; #define int long long #define double long double typedef pair<int, int> P_i; typedef pair<double, double> P_d; #define rep(i, n) for (int i = 0; i < (n); ++i) #define alrep(i, j, n) \ for (int i = 0; i < (n); ++i) \ for (int j = i + 1; j < (n); ++j) #define Yes cout << "Yes" << endl; #define No \ cout << "No" << endl; \ int ans = 0; #define answer cout << ans << endl; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int MOD = 1e9 + 7; const long long INF = 1LL << 60; signed main() { int N, K; double ans = -1; cin >> N >> K; double p[N]; rep(i, N) { cin >> p[i]; p[i] = (double)(p[i] + 1) / (double)2; } double res = 0; rep(i, K) { res += p[i]; } chmax(ans, res); rep(i, N - K) { res -= p[i]; res += p[i + K]; chmax(ans, res); } cout << fixed << setprecision(6) << ans << endl; return 0; }
replace
38
44
38
48
TLE
p02780
C++
Time Limit Exceeded
#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main(int argc, char *argv[]) { int N, K, i, j; cin >> N >> K; vector<double> q(N); int p; for (i = 0; i < N; i++) { cin >> p; for (j = 1; j <= p; j++) { q[i] += j; } q[i] /= p; } double ans = 0; for (i = 0; i <= N - K; i++) { double w = 0; for (j = i; j < i + K; j++) { w += q[j]; } if (ans < w) { ans = w; } } printf("%.6f\n", ans); return 0; }
#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main(int argc, char *argv[]) { int N, K, i, j; cin >> N >> K; vector<double> q(N); int p; for (i = 0; i < N; i++) { cin >> p; for (j = 1; j <= p; j++) { q[i] += j; } q[i] /= p; } double ans = 0; double w = 0; for (i = 0; i < K; i++) { ans += q[i]; } w = ans; for (i = K; i < N; i++) { w = w + q[i] - q[i - K]; if (ans < w) { ans = w; } } printf("%.6f\n", ans); return 0; }
replace
17
22
17
24
TLE
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second const long long MAXN = 1e5 + 10, inf = 1e18 + 21, LG = 20; int n, k; double p[MAXN], res; double ans; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { double a; cin >> a; p[i] = (a + 1) / 2; } for (int i = 0; i < k; i++) { ans += p[i]; res += p[i]; } for (int i = k; i < n; i++) { res -= p[i - k]; res += p[i]; ans = max(res, ans); } cout << fixed << setprecision(10) << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second const long long MAXN = 2e5 + 10, inf = 1e18 + 21, LG = 20; int n, k; double p[MAXN], res; double ans; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { double a; cin >> a; p[i] = (a + 1) / 2; } for (int i = 0; i < k; i++) { ans += p[i]; res += p[i]; } for (int i = k; i < n; i++) { res -= p[i - k]; res += p[i]; ans = max(res, ans); } cout << fixed << setprecision(10) << ans << '\n'; return 0; }
replace
7
8
7
8
0
p02780
C++
Time Limit Exceeded
#include <iomanip> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; double a = 0; double p[n]; for (int i = 0; i < n; i++) { cin >> a; p[i] = (1 + a) / 2; } double max = 0; for (int i = 0; i < n - k + 1; i++) { double max_b = 0; for (int j = 0; j < k; j++) { max_b += p[i + j]; } if (max < max_b) max = max_b; } cout << fixed << setprecision(12) << max; return 0; }
#include <iomanip> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; double a = 0; double p[n]; for (int i = 0; i < n; i++) { cin >> a; p[i] = (1 + a) / 2; } double s[n]; s[0] = p[0]; for (int j = 1; j < n; j++) { s[j] = p[j] + s[j - 1]; } double max = s[k - 1]; for (int i = k + 1; i < n; i++) { if (max < s[i] - s[i - k]) max = s[i] - s[i - k]; } cout << fixed << setprecision(12) << max; return 0; }
replace
13
21
13
22
TLE
p02780
C++
Runtime Error
// Garg's Code #include <bits/stdc++.h> #include <string.h> using namespace std; #define ll long long #define vec vector<ll> #define pb push_back #define po pop_back #define mp make_pair #define mt make_tuple #define F first #define S second #define f(i, x, n) for (ll i = x; i < n; i++) #define rf(i, x, n) for (ll i = x; i >= x; i--) #define all(c) c.begin(), c.end() #define fast() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1; const ll MIN = LLONG_MIN; const long double PI = 3.1415926535; const ll N = 100009; int main() { fast(); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ll t = 1; // cin >> t; while (t--) { ll n, k; cin >> n >> k; ll arr[n]; f(i, 0, n) cin >> arr[i]; long double brr[n]; f(i, 0, n) { brr[i] = ((arr[i] + 1) * (1.0)) / (2.0); // cout << brr[i] << " "; } // cout << endl; long double ans = -1, sum = 0; ll ptr = 0, init = 0; f(i, 0, n) { sum += brr[i]; ptr++; if (ptr >= k) { ans = max(ans, sum); sum -= brr[init]; ptr--; init++; } } cout << fixed << setprecision(8) << ans << endl; } return 0; }
// Garg's Code #include <bits/stdc++.h> #include <string.h> using namespace std; #define ll long long #define vec vector<ll> #define pb push_back #define po pop_back #define mp make_pair #define mt make_tuple #define F first #define S second #define f(i, x, n) for (ll i = x; i < n; i++) #define rf(i, x, n) for (ll i = x; i >= x; i--) #define all(c) c.begin(), c.end() #define fast() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1; const ll MIN = LLONG_MIN; const long double PI = 3.1415926535; const ll N = 100009; int main() { fast(); ll t = 1; // cin >> t; while (t--) { ll n, k; cin >> n >> k; ll arr[n]; f(i, 0, n) cin >> arr[i]; long double brr[n]; f(i, 0, n) { brr[i] = ((arr[i] + 1) * (1.0)) / (2.0); // cout << brr[i] << " "; } // cout << endl; long double ans = -1, sum = 0; ll ptr = 0, init = 0; f(i, 0, n) { sum += brr[i]; ptr++; if (ptr >= k) { ans = max(ans, sum); sum -= brr[init]; ptr--; init++; } } cout << fixed << setprecision(8) << ans << endl; } return 0; }
delete
26
30
26
26
0
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define x first #define y second #define mp make_pair #define pb push_back typedef long long ll; const ll MOD = 1e9 + 7; const ll INF = 1e9 + 5; const int MAXN = 500005; int n, k; double a[100005]; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); a[i] = double(x + 1) / 2; } double exp = 0; double maxx = 0; for (int i = 0; i < k; i++) { exp += a[i]; } maxx = exp; for (int i = k; i < n; i++) { exp -= a[i - k]; exp += a[i]; maxx = max(maxx, exp); } printf("%.7lf\n", maxx); return 0; }
#include <bits/stdc++.h> using namespace std; #define x first #define y second #define mp make_pair #define pb push_back typedef long long ll; const ll MOD = 1e9 + 7; const ll INF = 1e9 + 5; const int MAXN = 500005; int n, k; double a[200005]; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); a[i] = double(x + 1) / 2; } double exp = 0; double maxx = 0; for (int i = 0; i < k; i++) { exp += a[i]; } maxx = exp; for (int i = k; i < n; i++) { exp -= a[i - k]; exp += a[i]; maxx = max(maxx, exp); } printf("%.7lf\n", maxx); return 0; }
replace
16
17
16
17
0
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fi first #define sc second #define mp make_pair #define all(x) x.begin(), x.end() #define up(x, v) upper_bound(all(x), v) #define low(x, v) lower_bound(all(x), v) #define bin(x, v) binary_search(all(x), v) #define FOR(k, a, b) for (int k = (a); k < (b); ++k) #define ROF(k, a, b) for (int k = (a); k > (b); --k) #define pq priority_queue typedef long long ll; typedef unsigned long long ull; using vi = vector<int>; using ii = pair<int, int>; using vii = vector<ii>; int main() { int n, k; ios_base ::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; vi p(n); vector<double> preffix(n); preffix[0] = 0; FOR(i, 0, n) { cin >> p[i]; preffix[i + 1] = preffix[i] + (p[i] + 1.0) / 2.0; } double E = 0; FOR(i, k - 1, n) E = max(E, preffix[i + 1] - preffix[i - k + 1]); cout << fixed << setprecision(12) << E << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; #define fi first #define sc second #define mp make_pair #define all(x) x.begin(), x.end() #define up(x, v) upper_bound(all(x), v) #define low(x, v) lower_bound(all(x), v) #define bin(x, v) binary_search(all(x), v) #define FOR(k, a, b) for (int k = (a); k < (b); ++k) #define ROF(k, a, b) for (int k = (a); k > (b); --k) #define pq priority_queue typedef long long ll; typedef unsigned long long ull; using vi = vector<int>; using ii = pair<int, int>; using vii = vector<ii>; int main() { int n, k; ios_base ::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; vi p(n); vector<double> preffix(n + 1); preffix[0] = 0; FOR(i, 0, n) { cin >> p[i]; preffix[i + 1] = preffix[i] + (p[i] + 1.0) / 2.0; } double E = 0; FOR(i, k - 1, n) E = max(E, preffix[i + 1] - preffix[i - k + 1]); cout << fixed << setprecision(12) << E << '\n'; return 0; }
replace
33
34
33
34
0
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1000000000; // long long using ll = long long; // 出力系 #define print(x) cout << x << endl #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) // 最大公約数 unsigned gcd(unsigned a, unsigned b) { if (a < b) return gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } double ki(double a) { int su = 0; for (int i = 1; i <= a; i++) su += i; return su / a; } int main() { int N, K; cin >> N >> K; vector<int> p(N); REP(i, N) cin >> p[i]; double ans = 0; if (N == 1) { ans = ki(p[0]); cout << fixed << setprecision(10) << ans << endl; return 0; } ll sum = 0; REP(i, K) { sum += p[i + K]; } ll now = sum; int pos = 0; for (int i = 1; i + (K - 1) < N; i++) { now -= p[i - 1]; now += p[i + (K - 1)]; if (sum < now) pos = i; sum = max(sum, now); } for (int i = pos; i <= pos + (K - 1); i++) { ans += ki(p[i]); } cout << fixed << setprecision(10) << ans << endl; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1000000000; // long long using ll = long long; // 出力系 #define print(x) cout << x << endl #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) // 最大公約数 unsigned gcd(unsigned a, unsigned b) { if (a < b) return gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } double ki(double a) { int su = 0; for (int i = 1; i <= a; i++) su += i; return su / a; } int main() { int N, K; cin >> N >> K; vector<int> p(N); REP(i, N) cin >> p[i]; double ans = 0; if (N == 1) { ans = ki(p[0]); cout << fixed << setprecision(10) << ans << endl; return 0; } ll sum = 0; REP(i, K) { sum += p[i]; } ll now = sum; int pos = 0; for (int i = 1; i + (K - 1) < N; i++) { now -= p[i - 1]; now += p[i + (K - 1)]; if (sum < now) pos = i; sum = max(sum, now); } for (int i = pos; i <= pos + (K - 1); i++) { ans += ki(p[i]); } cout << fixed << setprecision(10) << ans << endl; }
replace
71
72
71
72
0
p02780
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> #define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++) #define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--) using namespace std; using ll = long long; using dll = deque<ll>; using pll = pair<ll, ll>; using qll = queue<ll>; using usll = unordered_set<ll>; using umll = unordered_map<ll, ll>; using sll = stack<int>; using vll = vector<ll>; using vvll = vector<vll>; constexpr ll kMod = 1e9 + 7; ll gcd(ll a, ll b) { if (a < b) { return gcd(b, a); } ll c = a % b; while (c != 0) { a = b; b = c; c = a % b; } return b; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } void init() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); } int main() { init(); ll N, K; cin >> N >> K; vector<double> P(N + 1, 0.0); vector<double> S(N + 1, 0.0); REP(i, 1, N + 1) { ll p; cin >> p; P[i] = (1.0 + p) / 2.0; S[i] = accumulate(P.begin(), P.begin() + i + 1, 0.0); } double ans = 0.0; for (ll i = 0; i + K <= N; i++) { ans = max(ans, S[i + K] - S[i]); } cout << ans << endl; return 0; }
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> #define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++) #define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--) using namespace std; using ll = long long; using dll = deque<ll>; using pll = pair<ll, ll>; using qll = queue<ll>; using usll = unordered_set<ll>; using umll = unordered_map<ll, ll>; using sll = stack<int>; using vll = vector<ll>; using vvll = vector<vll>; constexpr ll kMod = 1e9 + 7; ll gcd(ll a, ll b) { if (a < b) { return gcd(b, a); } ll c = a % b; while (c != 0) { a = b; b = c; c = a % b; } return b; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } void init() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); } int main() { init(); ll N, K; cin >> N >> K; vector<double> P(N + 1, 0.0); vector<double> S(N + 1, 0.0); REP(i, 1, N + 1) { ll p; cin >> p; P[i] = (1.0 + p) / 2.0; S[i] = S[i - 1] + P[i]; } double ans = 0.0; for (ll i = 0; i + K <= N; i++) { ans = max(ans, S[i + K] - S[i]); } cout << ans << endl; return 0; }
replace
69
70
69
70
TLE
p02780
C++
Runtime Error
#include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<long long> p(N); for (int i = 0; i < N; i++) { cin >> p[i]; } vector<long long> sum(N); sum[0] = p[0]; for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + p[i]; } long long ans = 0; for (int i = 0; i + K <= N; ++i) { ans = max(ans, sum[i + K] - sum[i]); } cout << fixed << setprecision(10) << (double)(ans + K) / 2 << endl; return 0; }
#include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<long long> p(N); for (int i = 0; i < N; i++) { cin >> p[i]; } vector<long long> sum(N + 1); sum[0] = p[0]; for (int i = 0; i < N; i++) { sum[i + 1] = sum[i] + p[i]; } long long ans = 0; for (int i = 0; i + K <= N; ++i) { ans = max(ans, sum[i + K] - sum[i]); } cout << fixed << setprecision(10) << (double)(ans + K) / 2 << endl; return 0; }
replace
12
13
12
13
-6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll MAXN = 1e5 + 51; ll cnt, x; double res, sum; double prob[MAXN]; inline ll read() { register ll num = 0, neg = 1; register char ch = getchar(); while (!isdigit(ch) && ch != '-') { ch = getchar(); } if (ch == '-') { neg = -1; ch = getchar(); } while (isdigit(ch)) { num = (num << 3) + (num << 1) + (ch - '0'); ch = getchar(); } return num * neg; } int main() { cnt = read(), x = read(); for (register int i = 0; i < cnt; i++) { prob[i] = 1.0 * (1 + read()) / 2; } for (register int i = 0; i < x; i++) { sum += prob[i]; } res = sum; for (register int l = 1, r = x; r < cnt; l++, r++) { sum = sum + prob[r] - prob[l - 1]; res = max(res, sum); } printf("%.12lf\n", res); }
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll MAXN = 5e5 + 51; ll cnt, x; double res, sum; double prob[MAXN]; inline ll read() { register ll num = 0, neg = 1; register char ch = getchar(); while (!isdigit(ch) && ch != '-') { ch = getchar(); } if (ch == '-') { neg = -1; ch = getchar(); } while (isdigit(ch)) { num = (num << 3) + (num << 1) + (ch - '0'); ch = getchar(); } return num * neg; } int main() { cnt = read(), x = read(); for (register int i = 0; i < cnt; i++) { prob[i] = 1.0 * (1 + read()) / 2; } for (register int i = 0; i < x; i++) { sum += prob[i]; } res = sum; for (register int l = 1, r = x; r < cnt; l++, r++) { sum = sum + prob[r] - prob[l - 1]; res = max(res, sum); } printf("%.12lf\n", res); }
replace
3
4
3
4
0
p02780
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define Rep(i, a, b) for (int i = a; i <= b; i++) #define _GLIBCXX_DEBUG #define Vl vector<ll> #define Vs vector<string> #define Vp vector<pair<ll, ll>> #define ll long long #define ALL(v) (v).begin(), (v).end() using namespace std; const double pi = acos(-1.0); const ll MOD = 1e9 + 7; const ll INF = 1LL << 60; using Graph = vector<vector<int>>; double kitai[200100]; int main() { ll n, k; cin >> n >> k; Vl p(n); rep(i, 0, n) cin >> p[i]; double bunsi = 0, bunbo; Rep(i, 1, 200000) { bunsi += i; bunbo = i; kitai[i] = bunsi / bunbo; } double ans = 0.0; Rep(i, 0, n - k) { double sum = 0.0; rep(j, i, i + k) { sum += kitai[p[j]]; } ans = max(ans, sum); } cout << fixed << setprecision(7) << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define Rep(i, a, b) for (int i = a; i <= b; i++) #define _GLIBCXX_DEBUG #define Vl vector<ll> #define Vs vector<string> #define Vp vector<pair<ll, ll>> #define ll long long #define ALL(v) (v).begin(), (v).end() using namespace std; const double pi = acos(-1.0); const ll MOD = 1e9 + 7; const ll INF = 1LL << 60; using Graph = vector<vector<int>>; double kitai[200100]; int main() { ll n, k; cin >> n >> k; Vl p(n); rep(i, 0, n) cin >> p[i]; double bunsi = 0, bunbo; Rep(i, 1, 200000) { bunsi += i; bunbo = i; kitai[i] = bunsi / bunbo; } double sum = 0.0; rep(i, 0, k) sum += kitai[p[i]]; double ans = sum; rep(i, 0, n - k) { sum -= kitai[p[i]]; sum += kitai[p[i + k]]; ans = max(ans, sum); } cout << fixed << setprecision(7) << ans << endl; return 0; }
replace
30
34
30
36
TLE
p02780
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; using ll = long long; template <typename T> using V = std::vector<T>; using Vi = V<int>; using VVi = V<V<int>>; using Vl = V<ll>; using VVl = V<V<ll>>; using Vs = V<string>; template <typename T1, typename T2> using P = std::pair<T1, T2>; using Pii = P<int, int>; using Pll = P<ll, ll>; using Pdd = P<double, double>; template <typename T1, typename T2> using M = std::map<T1, T2>; using Mii = M<int, int>; using Msi = M<string, int>; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REP2(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) #define RREP(i, s, e) for (int i = (int)(s); i >= (int)(e); --i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(), ie = (c).end(); i != ie; ++i) #define ALL(c) (c).begin(), (c).end() const double PI = acos(-1); const ll MOD = 1e9 + 7; int n, m, k; string s; int main() { cin >> n >> k; Vi v(n); REP(i, n) cin >> v[i]; V<double> ex(1001); REP2(i, 1, 1001) { double sum = i * (i + 1) / 2; ex[i] = sum / i; } double maxi = 0; REP(i, n - k + 1) { double a = 0; REP(j, k) { a += ex[v[i + j]]; } maxi = max(maxi, a); } printf("%.7f\n", maxi); return 0; }
#include "bits/stdc++.h" using namespace std; using ll = long long; template <typename T> using V = std::vector<T>; using Vi = V<int>; using VVi = V<V<int>>; using Vl = V<ll>; using VVl = V<V<ll>>; using Vs = V<string>; template <typename T1, typename T2> using P = std::pair<T1, T2>; using Pii = P<int, int>; using Pll = P<ll, ll>; using Pdd = P<double, double>; template <typename T1, typename T2> using M = std::map<T1, T2>; using Mii = M<int, int>; using Msi = M<string, int>; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REP2(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) #define RREP(i, s, e) for (int i = (int)(s); i >= (int)(e); --i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(), ie = (c).end(); i != ie; ++i) #define ALL(c) (c).begin(), (c).end() const double PI = acos(-1); const ll MOD = 1e9 + 7; int n, m, k; string s; int main() { cin >> n >> k; Vi v(n); REP(i, n) cin >> v[i]; V<double> ex(1001); REP2(i, 1, 1001) { double sum = i * (i + 1) / 2; ex[i] = sum / i; } double maxi = 0; double tmp = 0; REP(i, k) { tmp += ex[v[i]]; } maxi = tmp; REP2(i, 1, n - k + 1) { tmp -= ex[v[i - 1]]; tmp += ex[v[i + k - 1]]; maxi = max(maxi, tmp); } printf("%.7f\n", maxi); return 0; }
replace
47
51
47
54
TLE
p02780
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { double n, k, t; double ma = 0, ans = 0; vector<double> p; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> t; p.push_back((t + 1) / 2); } for (int i = 0; i < n - k + 1; i++) { double s = 0.0; for (int j = i; j < i + k; j++) { s += p[j]; } ans = max(ans, s); } cout << setprecision(10) << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { double n, k, t; double ma = 0, ans = 0; vector<double> p; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> t; p.push_back((t + 1) / 2); } for (int i = 0; i < k; i++) { ma += p[i]; } ans = ma; for (int i = k; i < n; i++) { ma += p[i] - p[i - k]; ans = max(ans, ma); } cout << setprecision(10) << ans << endl; return 0; }
replace
19
25
19
26
TLE
p02780
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, f, n) for (ll i = (f); (i) < (n); i++) #define repe(i, f, n) for (ll i = (f); (i) <= (n); i++) using namespace std; using ll = long long; ll INF = 1LL << 60; using G = vector<map<int, int>>; int main() { int N, K; cin >> N >> K; vector<double> arr(N); rep(i, 0, N) cin >> arr[i]; vector<double> ex(1001); for (double i = 1; i < 1001; i++) { ex[i] = (1 + i) / 2; } double comp = 0; rep(i, 0, K) { comp += ex[arr[i]]; } double ans = comp; for (int i = 1; i < N - 2; i++) { comp = comp - ex[arr[i - 1]] + ex[arr[K + i - 1]]; if (ans < comp) ans = comp; } cout << fixed << setprecision(10) << ans << endl; }
#include <bits/stdc++.h> #define rep(i, f, n) for (ll i = (f); (i) < (n); i++) #define repe(i, f, n) for (ll i = (f); (i) <= (n); i++) using namespace std; using ll = long long; ll INF = 1LL << 60; using G = vector<map<int, int>>; int main() { int N, K; cin >> N >> K; vector<double> arr(N); rep(i, 0, N) cin >> arr[i]; vector<double> ex(1001); for (double i = 1; i < 1001; i++) { ex[i] = (1 + i) / 2; } double comp = 0; rep(i, 0, K) { comp += ex[arr[i]]; } double ans = comp; for (int i = 1; i <= N - K; i++) { comp = comp - ex[arr[i - 1]] + ex[arr[K + i - 1]]; if (ans < comp) ans = comp; } cout << fixed << setprecision(10) << ans << endl; }
replace
23
24
23
24
0
p02780
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int sum(int n) { int ans = 0; if (n == 1) return 1; if (n % 2 == 0) { ans = (1 + n) * n / 2; } else { ans = (0 + n) * (n + 1) / 2; } return ans; } int main() { double n, k; cin >> n >> k; double ans = 0; vector<double> v(n); vector<double> p(n - k, 0); for (int i = 0; i < k; ++i) cin >> v[i]; for (int i = 0; i < k; ++i) { p[0] += sum(v[i]) / v[i]; } ans = p[0]; for (int i = k; i < n; ++i) { cin >> v[i]; p[i - k + 1] = p[i - k] - sum(v[i - k]) / v[i - k] + sum(v[i]) / v[i]; if (ans < p[i - k + 1]) ans = p[i - k + 1]; } cout << fixed << setprecision(15) << ans << endl; }
#include <bits/stdc++.h> using namespace std; int sum(int n) { int ans = 0; if (n == 1) return 1; if (n % 2 == 0) { ans = (1 + n) * n / 2; } else { ans = (0 + n) * (n + 1) / 2; } return ans; } int main() { double n, k; cin >> n >> k; double ans = 0; vector<double> v(n + 1); vector<double> p(n - k + 1, 0); for (int i = 0; i < k; ++i) cin >> v[i]; for (int i = 0; i < k; ++i) { p[0] += sum(v[i]) / v[i]; } ans = p[0]; for (int i = k; i < n; ++i) { cin >> v[i]; p[i - k + 1] = p[i - k] - sum(v[i - k]) / v[i - k] + sum(v[i]) / v[i]; if (ans < p[i - k + 1]) ans = p[i - k + 1]; } cout << fixed << setprecision(15) << ans << endl; }
replace
21
23
21
23
0