| Task: | Järjestys |
| Sender: | Alex |
| Submission time: | 2016-10-16 23:43:37 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.05 s | 1 | details |
| #2 | WRONG ANSWER | 0.06 s | 2 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int fb(std::vector<std::pair<long int, long int> >)':
input/code.cpp:26:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i++) {
^
input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:53:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i+=2) {
^
input/code.cpp:62:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < v.size(); i+=2) {
^
input/code.cpp:79:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < v.size(); j++) {
^
input/code.cpp:86:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
}else if(h==v....Code
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.cpp
* Author: alex
*
* Created on October 12, 2016, 11:14 AM
*/
#include <cstdlib>
using namespace std;
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
int fb(vector< pair<long , long> > v){
long b =0;
long r ;
for (int i = 0; i < v.size(); i++) {
if(v.at(i).first>b){
r=i;
b=v.at(i).first;
}
}
return r;
}
int main(int argc, char** argv) {
long n;
cin >> n;
long u[n];
vector< pair<long , long> > v;
vector< long > q;
for (int i = 0; i < n; i++) {
long a;
cin >> a;
v.push_back(make_pair(a,0));
}
long b =0;
long r1 ;
for (int i = 0; i < v.size(); i+=2) {
if(v.at(i).first>b){
r1=i;
b=v.at(i).first;
}
}
b =0;
long r2 ;
for (int i = 1; i < v.size(); i+=2) {
if(v.at(i).first>b){
r2=i;
b=v.at(i).first;
}
}
long f1 = v.at(r1).first+v.at(r2).first;
long c =1;
while(c<4){
vector< pair<long , long> > v2=v;
for (int j = 0; j < v.size(); j++) {
int y=0;
long h = fb(v2);
if(h==0){
if(v.at(h+1).second!=c&&v.at(h).second==0){
v.at(h).second=c;
}
}else if(h==v.size()-1){
if(v.at(h-1).second!=c&&v.at(h).second==0){
v.at(h).second=c;
}
}else
if(v.at(h-1).second!=c&&v.at(h+1).second!=c&&v.at(h).second==0){
if(v.at(h-1).first-v.at(h).first==3){
v.at(h-1).second=c;
v2.at(h-1).first=0;
y=1;
}else if(v.at(h+1).first-v.at(h).first==3){
v.at(h+1).second=c;
v2.at(h+1).first=0;
y=1;
}else
v.at(h).second=c;
}
if(y==0){
v2.at(h).first=0;
}else{
}
}
c++;
}
long a1=0;
long a2=0;
long a3=0;
for (int i = 0; i < v.size(); i++) {
if(v.at(i).second==1&&v.at(i).first>a1){
a1=v.at(i).first;
}
if(v.at(i).second==2&&v.at(i).first>a2){
a2=v.at(i).first;
}
if(v.at(i).second==3&&v.at(i).first>a3){
a3=v.at(i).first;
}
}
long f2 = a1 + a2 + a3;
if(f2>f1){
cout << f1 << " ";
cout << 2 << endl;
int x =1;
for (int i = 0; i < v.size(); i++) {
cout << x << " ";
if(x==1){
x=2;
}else{
x=1;
}
}
}else{cout << f2 << " ";
if(a3==0){
cout << 2 << endl;
}else{
cout << 3 << endl;
}
for (int i = 0; i < v.size(); i++) {
cout << v.at(i).second << " ";
}
}
return 0;
}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 9 3 4 7 6 5 10 2 8 1 |
| correct output |
|---|
| 32 10 10 9 10 9 8 7 9 4 2 1 4 5 2... |
| user output |
|---|
| 17 2 1 2 1 2 1 2 1 2 1 2 |
Test 2
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 1000 650 716 982 41 133 1000 876 92... |
| correct output |
|---|
| 3984 207 207 206 207 128 127 126 12... |
| user output |
|---|
| 1999 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 94703 47808 62366 31885 7091 8... |
| correct output |
|---|
| 399956 98676 98676 98675 98676 62994 ... |
| user output |
|---|
| (empty) |
