답안 #345540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345540 2021-01-07T14:42:19 Z Nursik Feast (NOI19_feast) C++14
4 / 100
59 ms 2668 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end() 
#define ld long double

using namespace std; 
 
void data() {
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif	
} 
void win()
{	
	ios_base::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
}

int block = 400;
const ld eps = 1e-6; 

const int N = 1e6 + 500;
const int mod = 1e9 + 7;

const ll hh = 100010683;
const ll hh2 = 150005819;

int n, k, g, pos;
int a[N];
ll s;
int main()
{
	data();              
	win();        
	cin >> n >> k;
	bool was = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		was = was | (a[i] < 0), s += a[i];
		if (a[i] < 0)
			g++, pos = i;
	}
	//first subtask
	if (was == 0)
	{
		cout << s << '\n';
		return 0;
	}
	//second subtask
	if (g == 1 && k >= 2)
	{
		cout << s - a[pos] << '\n';
		return 0;	
	}
	else if (g == 1 && k == 1)
	{
		cout << s;
		return 0;
	}
}

# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1520 KB Output is correct
2 Correct 34 ms 1516 KB Output is correct
3 Correct 39 ms 1516 KB Output is correct
4 Correct 36 ms 1468 KB Output is correct
5 Correct 39 ms 1516 KB Output is correct
6 Correct 38 ms 1484 KB Output is correct
7 Correct 36 ms 1468 KB Output is correct
8 Correct 44 ms 1516 KB Output is correct
9 Correct 34 ms 1516 KB Output is correct
10 Correct 43 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1520 KB Output is correct
2 Correct 24 ms 2668 KB Output is correct
3 Incorrect 23 ms 2668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1520 KB Output is correct
2 Correct 34 ms 1516 KB Output is correct
3 Correct 39 ms 1516 KB Output is correct
4 Correct 36 ms 1468 KB Output is correct
5 Correct 39 ms 1516 KB Output is correct
6 Correct 38 ms 1484 KB Output is correct
7 Correct 36 ms 1468 KB Output is correct
8 Correct 44 ms 1516 KB Output is correct
9 Correct 34 ms 1516 KB Output is correct
10 Correct 43 ms 1516 KB Output is correct
11 Correct 25 ms 1520 KB Output is correct
12 Correct 24 ms 2668 KB Output is correct
13 Incorrect 23 ms 2668 KB Output isn't correct
14 Halted 0 ms 0 KB -