Submission #1761754


Source Code Expand

#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 105
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n;
LL A[M],B[M];
set<int> fact[M];
void addFact(int x,int a)
{
	for(int j=2*x; j<=n; j+=x)
	{
		B[j] += A[x]*a;
		
		if(a==1) fact[j].insert(x);
		else fact[j].erase(x);
	}
}
int main()
{
	while(~scanf("%d",&n))
	{
		REP(i,1,n) scanf("%lld",&A[i]);
		MSET(B, 0);
		REP(i,0,n) fact[i].clear();

		LL ans = 0;
		REP(i,1,n)
		{
			if (A[i]+B[i]>=0)
			{
				ans += A[i] + B[i];
				vector<int> tmp;
				for(int j:fact[i]) tmp.PB(j);
				for(int j:tmp) addFact(j, -1);
			}
			else
			{
				addFact(i, 1);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Submission Info

Submission Time
Task E - MUL
User Nekosyndrome
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1096 Byte
Status WA
Exec Time 1 ms
Memory 256 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,1,n) scanf("%lld",&A[i]);
                                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 20
WA × 29
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All example_0, example_1, example_2, example_3, kimeuti_0, kimeuti_1, kimeuti_10, kimeuti_11, kimeuti_12, kimeuti_13, kimeuti_14, kimeuti_15, kimeuti_16, kimeuti_17, kimeuti_18, kimeuti_19, kimeuti_2, kimeuti_3, kimeuti_4, kimeuti_5, kimeuti_6, kimeuti_7, kimeuti_8, kimeuti_9, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_16, rand_17, rand_18, rand_19, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9, small_0, small_1, small_2, small_3, small_4
Case Name Status Exec Time Memory
example_0 AC 1 ms 256 KiB
example_1 AC 1 ms 256 KiB
example_2 AC 1 ms 256 KiB
example_3 AC 1 ms 256 KiB
kimeuti_0 AC 1 ms 256 KiB
kimeuti_1 WA 1 ms 256 KiB
kimeuti_10 WA 1 ms 256 KiB
kimeuti_11 WA 1 ms 256 KiB
kimeuti_12 WA 1 ms 256 KiB
kimeuti_13 WA 1 ms 256 KiB
kimeuti_14 WA 1 ms 256 KiB
kimeuti_15 AC 1 ms 256 KiB
kimeuti_16 WA 1 ms 256 KiB
kimeuti_17 AC 1 ms 256 KiB
kimeuti_18 WA 1 ms 256 KiB
kimeuti_19 WA 1 ms 256 KiB
kimeuti_2 WA 1 ms 256 KiB
kimeuti_3 WA 1 ms 256 KiB
kimeuti_4 WA 1 ms 256 KiB
kimeuti_5 WA 1 ms 256 KiB
kimeuti_6 AC 1 ms 256 KiB
kimeuti_7 AC 1 ms 256 KiB
kimeuti_8 WA 1 ms 256 KiB
kimeuti_9 AC 1 ms 256 KiB
rand_0 WA 1 ms 256 KiB
rand_1 AC 1 ms 256 KiB
rand_10 WA 1 ms 256 KiB
rand_11 AC 1 ms 256 KiB
rand_12 WA 1 ms 256 KiB
rand_13 AC 1 ms 256 KiB
rand_14 WA 1 ms 256 KiB
rand_15 WA 1 ms 256 KiB
rand_16 WA 1 ms 256 KiB
rand_17 WA 1 ms 256 KiB
rand_18 WA 1 ms 256 KiB
rand_19 AC 1 ms 256 KiB
rand_2 WA 1 ms 256 KiB
rand_3 AC 1 ms 256 KiB
rand_4 WA 1 ms 256 KiB
rand_5 WA 1 ms 256 KiB
rand_6 AC 1 ms 256 KiB
rand_7 AC 1 ms 256 KiB
rand_8 WA 1 ms 256 KiB
rand_9 AC 1 ms 256 KiB
small_0 AC 1 ms 256 KiB
small_1 WA 1 ms 256 KiB
small_2 AC 1 ms 256 KiB
small_3 WA 1 ms 256 KiB
small_4 WA 1 ms 256 KiB