Show all threads Hide all threads Show all messages Hide all messages |
Hint - WA 5 | Nafania | 1026. Questions and Answers | 15 Apr 2022 11:38 | 2 |
if you got WA on this test try to change SHORT on INT or CHAR. it looks like an error in task. Nafania is right. There is a mistake in test. |
My AC on C# | Xeqlol | 1026. Questions and Answers | 29 Nov 2019 18:29 | 3 |
maybe it is not the best solution, but using System; using System.Collections.Generic; namespace _1026 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<int> z = new List<int>(); for(int i = 0; i < n; i++) z.Add(int.Parse(Console.ReadLine())); z.Sort(); Console.ReadLine(); int k = int.Parse(Console.ReadLine()); for (int i = 0; i < k; i++) Console.WriteLine(z[int.Parse(Console.ReadLine())-1]); } } } well.... C# helps a lot. but i really think figure out yourself is better. PS: no sort is required actually. If you know the length of array it is better to create array, not to use List<>. Array is faster :) In this case you needn`t a lot of economy of time, but in some cases this can be critical. |
This is too easy | gunfighter(ノ-_-)ノ彡┻━┻ | 1026. Questions and Answers | 16 Apr 2019 23:50 | 1 |
Wonder why this task has a 147 complexity. Just sort and write |
accepted | Mikhail | 1026. Questions and Answers | 6 Jun 2018 02:00 | 1 |
//#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; const int maxn = (int) 1e5; int a[maxn]; int main() { int n, x; cin >> n; fo(i, n) { cin >> a[i]; } sort(a, a + n); string str; cin >> str >> n; fo(i, n) { cin >> x; cout << a[x - 1] << '\n'; } re 0; } |
Disappointment | Rabbit Girl ♥ | 1026. Questions and Answers | 2 Dec 2017 00:50 | 1 |
Just sort() numbers... It will take approximately 1e5 * log(1e5) ≈ 1e6 operations, which is not that long to compute. Edited by author 02.12.2017 00:54 |
Linear Short Solve | brainail | 1026. Questions and Answers | 6 Apr 2016 22:46 | 2 |
var b,a:array[0..100010]of longint; x,i,n:longint; begin readln(n); for i:=1 to n do begin readln(x); inc(a[x]); end; x:=0; for i:=0 to 5000 do while(a[i]>0)do begin inc(x); dec(a[i]); b[x]:=i; end; readln; readln(n); for i:=1 to n do begin read(x); writeln(b[x]); end; end. Edited by author 20.01.2010 18:28 I think size of array "a" is too big(the range of values lies between 1 and 5000)..... ....and of array"b" too (max number of values is 100000 but not 1000010); Edited by author 06.04.2016 22:53 |
Problem difficulty | Marius Žilėnas | 1026. Questions and Answers | 6 Apr 2016 21:38 | 2 |
This problem can be solved without realisation of sorting. :) If you mean counting sort then it also sorting but without changing places:) Else say pls what is it... |
lol | Dionis | 1026. Questions and Answers | 6 Apr 2016 20:13 | 8 |
lol Dionis 6 Dec 2007 19:38 Lol 1.5 года назад когда зарегился только задачи такими трудными казались а счас) Вообще лехкотня. Удачи всем парни! Re: lol SorrowAngel 24 Apr 2008 14:37 I THINK YOU REALLY GOOD MAN Re: lol Baranova_ED(YSPU) 28 Dec 2008 22:57 почему только парни? дискриминация Re: lol SevenEleven [Tartu U] 29 Dec 2008 19:46 I think that your are mistaken thinking that problem will became soon easy for you. They will all times be rather difficult because of competition nature of human life as Marks said. Re: lol Fyodor Menshikov 30 Dec 2008 14:57 лехкотня Жаль, по русскому языку аналога Тимуса нет. Dionis 47 задач за полтора года. Слабовато... Edited by author 30.12.2008 21:02 lol я решил больше за 1,5 месяца |
Why WA1??? | sirenko.anas | 1026. Questions and Answers | 16 Mar 2016 19:21 | 1 |
program z1026; var n,k,i,j,nomer:integer; count:array[1..5000]of integer; a,rez:array[1..100000]of integer; z:array[1..100]of integer; s:string; begin read(n); for i:=1 to n do read(a[i]); read(s); read(k);
for i:=1 to 5000 do count[i]:=0; for i:=1 to n do inc(count[a[i]]); nomer:=1; for i:=1 to 5000 do for j:=1 to count[i] do begin rez[nomer]:=i; inc(nomer); end; for i:=1 to k do read(z[i]); for i:=1 to k do writeln(rez[z[i]]); end. Answer for test1 is 121 121 7 123 |
чтение данных | lucshiiiulian | 1026. Questions and Answers | 18 Jan 2015 20:32 | 2 |
алгоритм сделал и работает, но не проходит проверку, говрит что напечатал слишком много букафф,,, мне кажется я неправильно читаю К, не знаю как перепрыгнуть через те решетки :( int K; char ch; scanf("%s%d",&ch,&K); |
AC - 0.031, 152 KB: No need to keep the numbers in memory | Soucup Adrian | 1026. Questions and Answers | 19 Nov 2012 17:30 | 2 |
Edited by author 15.12.2012 09:15 chufff Hint: Keep only their frequencies and see what you can do from there. Edited by author 28.06.2012 20:47 Hint: Keep only their frequencies and see what you can do from there. Edited by author 28.06.2012 20:47 Hint: Keep only their frequencies and see what you can do from there. Edited by author 28.06.2012 20:47 |
hint | martin | 1026. Questions and Answers | 8 Aug 2012 16:53 | 1 |
hint martin 8 Aug 2012 16:53 |
Quick Sort WA#3???What's the problem? | RezistaL | 1026. Questions and Answers | 16 Jan 2012 16:52 | 3 |
When i use bubble alg i have TLE #5(it's normal, i understand that), but when i use quick sort, i have WA#3, why??? What is wrong? probably something wrong with your quicksort i use quick sort and got ac.you have something wrong in code. |
Can smbd explain me the example? | Hi4ko | 1026. Questions and Answers | 16 Jan 2012 16:51 | 2 |
Edited by author 15.12.2011 23:01 it's easy . there is n numbers you should sort them and when they ask you "Which element is i-th by its value?" you shoul print i-th element from your sorted array |
(java)be dangerous, use .trim() | Sni | 1026. Questions and Answers | 5 Jan 2012 02:04 | 4 |
I used BufferedReader and got crash on test 3 without .trim() i used Scanner and all became Ok. But with BufferedReader and .trim() i've got any crashes. It seems that i don't know how to cook it |
Help!!! Time Limit!!! | Vladzick | 1026. Questions and Answers | 30 Nov 2011 03:08 | 3 |
here is my program var a,b:array[1..100000] of longint; i,k,l,n,m:longint; f1,f2:text; s:string; begin readln(n); for i:=1 to n do readln(a[i]); readln(s); readln(m); for k:=1 to m do readln(b[k]); for k:=1 to n do for i:=2 to n do if a[i]<a[i-1] then begin l:=a[i]; a[i]:=a[i-1]; a[i-1]:=l; end; for i:=1 to m do writeln(a[b[i]]); readln; end. You should use fast sort buble sort too long qsort fast enough use hash, no necessary to sort actually. |
What is wrong im my code??? | Swifty | 1026. Questions and Answers | 27 Nov 2011 18:03 | 2 |
var hash:array [1..5001] of longint; i,j,k,n,m,ch,zap:longint; s:string; begin readln(n); for i:=1 to n do begin readln(ch); inc(hash[ch]); end; readln(s); readln(k); for i:=1 to k do begin readln(zap); for j:=1 to 5000 do begin if zap<1 then begin writeln(j-1); break; end else zap:=zap-hash[j]; end; end; end. WA Test #2.... the main thing wrong with your code is it's in pascal :D |
WA #5 | RobertKhasanov | 1026. Questions and Answers | 18 Oct 2011 20:26 | 4 |
WA #5 RobertKhasanov 13 Dec 2006 15:32 Re: WA #5 [SESC USU] Zhirov Eugene 3 Nov 2009 19:12 WA 5 =( I don't know where the mistake can be... don't use SHORT use INT or CHAR instead. I got crash on this test and it helps me to get AC. P.S.: Sorry for my English :) |
CRASH | d000179 | 1026. Questions and Answers | 16 Jun 2009 13:18 | 1 |
CRASH d000179 16 Jun 2009 13:18 Could anyone help me? This code get CRASH... #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { // Input Database int num_elem_db; cin >> num_elem_db; vector<int> data_vector (num_elem_db, 0); // Vector for data for (int i = 0; i < num_elem_db; ++i) { int aux_elem; cin >> aux_elem; data_vector[i] = aux_elem; } cout << "###" << endl; // SORTING VECTOR OF DATA sort( data_vector.begin( ), data_vector.end( ) ); // Input queries int num_queries; cin >> num_queries; vector<int> query_vector (num_queries, 0); // Vector for queries for (int j = 0; j < num_queries; ++j) { int aux_query; cin >> aux_query; query_vector[j] = aux_query; } for (int k = 0; k < num_queries; ++k) { cout << data_vector[query_vector[k]-1] << endl; } return 0; } |
"it may contain up to 100 000 those numbers." | Megatron | 1026. Questions and Answers | 4 Feb 2009 10:12 | 1 |
if you miss it, you will crash on #5 |